By DrupalNovice on
Is it possible to alter/modify HTML in $block->content?
This code:
function phptemplate_preprocess_block(&$vars) {
if (isset($vars['block']->module)) {
print_r($vars);
}
}
gives me an array that looks something like this:
Array
(
[template_files] => Array
(
[0] => block-header
[1] => block-locale
[2] => block-locale-0
)
[block] => stdClass Object
(
[bid] => 68
[module] => locale
[delta] => 0
[theme] => test_theme
[status] => 1
[weight] => -4
[region] => header
[custom] => 0
[throttle] => 0
[visibility] => 0
[pages] =>
[title] =>
[cache] => -1
[enabled] => 1
[page_match] => 1
[subject] => Languages
[content] => <ul><li class="en first active"><a href="/drupal/admin/settings/performance" class="language-link active">English</a></li>
<li class="fi"><a href="/drupal/fi/admin/settings/performance" class="language-link">Suomi</a></li>
<li class="ge last"><a href="/drupal/ge/admin/settings/performance" class="language-link">German</a></li>
</ul>
)
[zebra] => even
[id] => 2
[directory] => sites/all/themes/test_theme
[is_admin] => 1
[is_front] =>
[logged_in] => 1
[db_is_active] => 1
[user] => stdClass Object
(
[uid] => 1
[name] => devel
[pass] => daf98543c487af6ceb230cae002c92fd
[mail] =>
[mode] => 0
[sort] => 0
[threshold] => 0
[theme] =>
[signature] =>
[signature_format] => 0
[created] => 1246737002
[access] => 1254486552
[login] => 1254471866
[status] => 1
[timezone] => 10800
[language] =>
[picture] =>
[init] =>
[data] => a:0:{}
[timezone_name] => Europe/Helsinki
[sid] => b4dfa9b155b2dde83dca1d489b73ee45
[hostname] => ::1
[timestamp] => 1254486648
[cache] => 0
[session] =>
[roles] => Array
(
[2] => authenticated user
)
)
[block_zebra] => odd
[block_id] => 1
)
It is the HTML after [content] => I'd like to change.
Anyway in doing that?
Comments
It depends on the block,
It depends on the block, many(most) blocks from modules use a theme function to produce the HTML. In these cases you can override the theme function.
Ok, thanks
Ok, thank you for the clarification.
What about changing the block
What about changing the block title: ['block']['subject']
I know, I know, I can do this in the /admin/build/block page, but I would like to change this per arg(0). E.g. when on my news page (/news) I'd like the title of the search block to be "Search news" instead of the default "Search".
Any ideas on how to achieve this? Should this be done in the theme layer (template.php) or in a module?
Is this correct approach to
Is this correct approach to change the subject or title or any block?