0

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();
              break;
          }
          return $block;
        }

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

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 Jul 4 '12 at 7:16
1

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.

-3

I think you may losing a hook:

function custom_theme(){

}

  • 1
    Can you expand on this a little bit? – mpdonadio Nov 6 '13 at 17:04

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.