runeveryday
runeveryday

Reputation: 2799

how to override $block->content in drupal?

Now, if i want to override the $block->content which is generated by the Book module... how can I override it and customize the title list? thank you.

Upvotes: 1

Views: 6293

Answers (3)

Mehul Jethloja
Mehul Jethloja

Reputation: 637

you can use a preprocess_block function

function yourthemename_preprocess_block(&$vars)
{
     if(isset($vars['block']))
     {
          //i have override a footer_block 
          if($vars['block']->region == 'footer_block')
          {
              $vars['content] = "Please Enter Some data";
          }
     }
}

Upvotes: 2

PPC-Coder
PPC-Coder

Reputation: 3632

The $vars argument will have all the information about the blocks being themed. In your case you want the module to be "book".

function phptemplate_preprocess_block(&$vars) {    
    if (isset($vars['block'])) {
      if($vars['block']->module == 'book') {
        $vars['block']->content = "My new content";
      }
    }
  }

Upvotes: 2

Haza
Haza

Reputation: 2999

You can use the preprocess_block function

function phptemplate_preprocess_block(&$vars) {
  if (isset($vars['block'])) {
      print_r($vars);
    }
  }

And dig into those results.

About the content, is this is a module generated block, I hope that $content is renderer using a theme() function, so you just need to alter it.

Upvotes: 5

Related Questions