3

I'm spending more and more time here, and constantly wishing Drupal was easier to understand then I'm finding it, oh well :)

so todays question is, I'm trying to remove the "2 comment" and "1 new comment" links from a node in Teaser view. I do however want to keep the "Read More" and "Add new Comment" links.

So I've found all this is stored in "print render($content['links']);"

I have also discovered that "Read More" can be requested using "print render($content['links']['node']);" and all 3 comment links can be pulled out using "print render($content['links']['comment']);"

What I cannot work out is how to break down the Comment part so I can strip out the 2 I dont need.

anyone know?

thanks in advance.

Purplemonkey
  • 1,927
  • 3
  • 27
  • 39
  • hi, I believe I have found the function I want to override "function comment_node_view($node, $view_mode) " its in the comment.module file in the comment modules folder. I can't seem to effect it though when I try to override it by putting it in my Template.php file and add my theme_ to the function name? – Purplemonkey Aug 18 '11 at 07:59

2 Answers2

3

To expand on what @coleopterist said, the following worked well for me:

mytheme_node_view_alter(&$build) {
    if ($build['#view_mode'] == 'teaser') {
        $build['links']['node']['#links']['node-readmore']['title'] = t('Read More »');
    }
}
zzzzBov
  • 174,988
  • 54
  • 320
  • 367
3

The functions that you are looking for are probably hook_node_view_alter and hook_comment_view_alter.

FYI, a quick fix is also possible via CSS where you can simply hide the offending DIV.

  • Thanks for you answer, I will give it ago as soon as I can. I try to aviod the CSS hide solution as I want less server overheads. I find Drupal quite heavy weight at best. – Purplemonkey Oct 12 '11 at 14:48