drupal-7drupal-modulesdrupal-viewsdrupal-themingdrupal-blocks

Different Layouts for Different Blocks in a Custom Module Drupal 7


I have created Custom Module which that works with a Custom Content type. In my module, withe use of a multi-step form I am grabbing details form the user and in final form submit, creating a node pragmatically.

I want to define two blocks in my module, one block display my data (custom content type) for end users and another block to display my data (custom content type) for logged-in users.

The problem Im facing is, I have to present in these two blocks in completely deferent ways. So what would be the best approach to give these two blocks different layout/styles to achieve my goal?

In summary, what i want to do is,

  1. Define two Blocks in my custom module.
  2. Give completely different layouts/styles for these two Blocks.

Thank you, PIKP


Solution

  • You can specify 2 different template files (one for each block) by naming the template file using this pattern: block--MODULE--DELTA.tpl.php.

    Just copy the original block template block.tpl.php from modules/block folder to your default theme, and rename it as explained above. Flush the cache. And you are good to go.

    More about drupal template suggestions.