问题
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.
回答1:
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.
回答2:
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";
}
}
}
回答3:
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";
}
}
}
来源:https://stackoverflow.com/questions/5320092/how-to-override-block-content-in-drupal