I have created a block-custom.tpl.php, the following is the code inside:

<strong>Hello World</strong>
<p>Subject:<?php print $block->subject ?></p>
<p>Content:<?php print $block->content ?></p>

My custom module code:

        function custom_block_info() {
          $blocks['my-block-id'] = array(
            'info' => t('Block Name'),
          return $blocks;

         * Implementation of hook_block_view().
        function custom_block_view($delta='') {
          $block = array();
          switch ($delta) {
            case 'my-block-id':
              $block['subject'] = t('Block Name');
              $block['content'] = custom_contents();
          return $block;

         * custom html block
         * @return string
        function custom_contents() {
          return '
            </p><div class="body">
              Hello World, this is a example custom Block

I placed the tpl file in /module/block/ directory

I followed the tutorial of the following web page (I know it is for Drupal 6) http://eureka.ykyuen.info/2010/11/11/drupal-customize-block-template-file/

Of course, the result is nothing, anything I am missing? How to override the block.tpl.php?

  • 5
    If you are using drupal 7, it would be called block--custom.tpl.php and would normally be put in a theme directory, not a core module directory.
    – Jimajamma
    Commented Jul 4, 2012 at 7:16

2 Answers 2


You have to put your code into an custom module. Creating Drupal 7.x modules should get you going. You should never change code of core. This will be lost (or at least causes tidious manual work) the next time you update drupal.


I think you may losing a hook:

function custom_theme(){


  • 1
    Can you expand on this a little bit?
    – mpdonadio
    Commented Nov 6, 2013 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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