Drupal 6. Alter links
Julia 16/01/2010
How to remove unnecessary links from the group of links under node.
There are two methods for altering links, one at theme layer and the other hrough a custom module.
Use hook_link_alter() in a module
<?php
function mymodule_link_alter(&$links, $node) {
foreach ($links as $module => $link) {
if (strstr($module, 'blog')) {
unset($links[$module]);
}
}
}
?>At theme layer
In the template.php file:
change or create the new function phptemplate_preprocess_node(&$vars)
<?php
function phptemplate_preprocess_node(&$vars) {
// unset from links forward link
foreach ($vars['node']->links as $module => $link) {
if ($module == 'forward_links') {
unset($vars['node']->links[$module]);
}
}
$vars['links'] = theme('links', $vars['node']->links, array('class' => 'links inline'));
}
?>In this example I removed all links conneted with 'forward' module
Отправить новый комментарий