开发者

Drupal 7, trying to "theme" the node links i.e. "Add new Comment" "Read More" etc

开发者 https://www.devze.com 2023-03-29 06:42 出处:网络
I\'m spending more and more time here, and constantly wishing Drupal was easier to understand then I\'m finding it, oh well :)

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 ho开发者_Go百科wever 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.


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.


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 »');
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号