开发者

how to override $block->content in drupal?

开发者 https://www.devze.com 2023-02-16 21:43 出处:网络
Now, if i want to overr开发者_运维问答ide the $block->content which is generated by the Book module... how can Ioverride it and customize the title list? thank you.You can use the preprocess_block fun

Now, if i want to overr开发者_运维问答ide the $block->content which is generated by the Book module... how can I override it and customize the title list? thank you.


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.


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";
      }
    }
  }


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";
          }
     }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消