I have been reading over this node

http://drupal.org/node/44708

how would it be different for drupal 6

thanks, i am just not sure what replaces

_phptemplate_callback

Comments

XerraX’s picture

subscribing

ReAliTy iS JuST a DrEAm. HaCk ThE PLaNet!

WorldFallz’s picture

I alter links by inserting the following into the template.php file for the theme:

function phptemplate_links($links, $attributes = array()) {
    //do whatever to links here

    return theme_links($links, $attributes);
}

You can also do it in a custom module with hook_link_alter.

talino’s picture

It works for removing unwanted links with unset(), however for some reason it blanks out the attributes passed to it by other modules (such as comments and calendar). Specifically, untouched 'ul' tags are stripped of the class="links" attribute. Here's my code in template.php:

function mytheme_links($links, $attributes = array()) {
    unset($links['comment_add']);
    unset($links['comment_comments']);
    unset($links['node_read_more']);
    return theme_links($links, $attributes);
}

It removes the links just fine but messes up display on Calendar and Comments (among others).

It works when I put it in a custom module, like so:

function mytheme_link_alter(&$links, $node) {
  unset($links['comment_add']);
  unset($links['comment_comments']);
  unset($links['node_read_more']);
}

The inner workings of this escape me, because I've tried passing $links by reference (&$links) in template.php and it didn't work. Only the module way seemed to be possible. Why is that?

Oleksa-1’s picture

@talino,WorldFallz

wrong

function mytheme_links($links, $attributes = array()) {
    unset($links['comment_add']);
    unset($links['comment_comments']);
    unset($links['node_read_more']);
    return theme_links($links, $attributes);
}

correct

function mytheme_links($links, $attributes = array('class' => 'links')) {
    unset($links['comment_add']);
    unset($links['comment_comments']);
    unset($links['node_read_more']);
return theme_links($links, $attributes = array('class' => 'links'));
}
wooody’s picture

Thanks a lot, works with me perfect.

function phptemplate_links($links, $attributes = array()) {
unset($links['node_read_more']);				//remove ReadMore Link in Teaser
return theme_links($links, $attributes);
}