drupaldrupal-7drupal-blocks

Drupal 7. How I change content in custom block via template.php?


I created simple block in admin page with HTML content and now I need to modify this content via template.php. What need for this?


Solution

  • You should name your .tpl file based on your block ID.

    For example:

    If you've created block with an ID

    block-block-1

    then the template name should be

    block--block--1.tpl.php
    

    Main steps:

    NOTE: When you're editing your custom block you can see in URL the path with block's delta. It will be something like

    /admin/structure/block/manage/block/5/configure
    

    For this URL, you should use block--block--5.tpl.php. The number 5 is block's delta in this case. You can also view the source of the page where your block appears (or use Firebug to inspect) and look for the ID given to the block.