I have a block that I have templated and want to use in and out of a panel layout in various parts of my site.

So to template the block I opted to install the block_machine_name module which gives a good anchor point for the template so the block id is not relied upon (as this changes between my dev and prod sites).

Then I theme the block and it works just great using a template name like block--sweet-name.tpl.php

Then I also use the block in a panels layout and things start to go wrong. The block template is now ignored.

So I am trying to find a way to get panels embedded block to respect block templates.

Is this possible?

  • I overlooked trying to template the block using the block--block-7.tpl.php style templates and this does work in and out of panels. However I still would prefer to use the machine name style template for both so now I need to figure out how to get this working with panels. – dibs Nov 5 '13 at 10:06

If you need to use the block template in panels, make sure you choose the style from the panels option to be "Systems block".

Panel Style

This lets you use block--sweet-name.tpl.php.

| improve this answer | |
  • Nice one! I will try this. – dibs Jan 26 '15 at 19:59

If you have machine name based block templates and you need to also use non machine name block templates as in this example then you can just make a non machine name block template that includes the machine name one. Though still not ideal it could.

    //use the mchine name block
    $path = drupal_get_path('theme', 'myTheme');

If anyone has a better solution though I am all ears.

| improve this answer | |

I suggest trying this little backport from Drupal 8. https://www.drupal.org/node/2307505

It will show you all the templates and their suggestions which surround the output of your block. And in this case, it will likely be a pane template.

   * panels-pane--block--sweet-module-sweet-name.tpl.php
   * panels-pane--block.tpl.php
   x panels-pane.tpl.php
| improve this answer | |

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.