What is the correct way to display parts of a highly customized application? For example my website only consists of a friendlist with user name as well as images and a live chat frame.

Is this the right approach?

  1. Create Theme with 2 regions (friend_list, chat_frame)
  2. Develop custom Blocks for each feature (friend_list Block and chat_frame Block)
  3. Assign Blocks to the regions
  4. Style each Block individually to fit my requirements
  5. Add javascript for each block for chat and asynchronous updating of the friendlist (ajax)

Is it better to place all features in one module? Can one module have multiple blocks?


Looks like this is a job better suited for a JavaScript web app (Angular, React, etc.) than using Drupal to render the UI. You can create a dummy module whose only job is to load the JavaScript for your webapp. Then it's all JS from there.

For the back end, assuming Drupal is also powering the data layer, you can use the REST API features of the Views module to send and retrieve data.

Additionally, I wouldn't use block layout for the layout of the site since it's a global layout. This hampers further customization of the layout of the site. Consider using Panels to create dedicated pages that have their own layout. Imagine block layout, but only for a specific page or set of pages.

| improve this answer | |
  • Thanks for your great answer! It helps a lot to clarify things. Sadly I'm not allowed to use an external frontend. Do you recommend me to use panels for this task? Drupals REST API is a great thing and i'm already familiar with it. – Towen May 19 '17 at 13:24
  • @Towen I see. Then yes, Panels with custom blocks would be a good way to do this. – Joseph May 19 '17 at 13:59
  • So should I use Drupals REST API and jQuery Ajax or the Drupal Ajax API. I have to say that I need to request data from Drupal backend async when certain websocket data is transmitted to my Javascript from a nodejs server. – Towen May 19 '17 at 21:19
  • @Towen Whether it's D8 Rest+jQuery vs Drupal Ajax is up to you. I would prefer REST though, as it is platform-independent. – Joseph May 19 '17 at 21:23
  • Is it possible that all blocks are using the same instance of a javascript file? It's imoportant to stay connected to a websocket server to retrieve some data and fill that into these blocks. – Towen May 21 '17 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.