1

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
3

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.

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

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.

<?php
    //use the mchine name block
    $path = drupal_get_path('theme', 'myTheme');
    include($path."/templates/block--sweet-name.tpl.php");
?>

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

0

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.

<!-- FILE NAME SUGGESTIONS:
   * panels-pane--block--sweet-module-sweet-name.tpl.php
   * panels-pane--block.tpl.php
   x panels-pane.tpl.php
-->

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.