0

i have a View that displays some DVD product teasers. What id like to do is customize or change the wording of the 'Read More' link of each teaser.

i also have another view where i want to remove that link altogether. now i know how to do this with CSS but i'm trying to learn how to override theme functions.

i have Themer Info turned on see a candidate function name for theme_link() but i think that would override all the theme_link functions for the entire site. how do i customize theme_link() for a particular node?

and how do i find out what function calls theme_link() ?, if i want to remove it entirely?

in other words, i need to get into $content variable!, how do i do that?

much thanks in advance!

2 Answers 2

1

You can use hook_node_view_alter(&$build) and overwrite the link. Here is an example to change the Read More title and removing Add comment link. You can use dpm() function of devel module to see the array structure.

function mymodule_node_view_alter(&$build){
  if($build['#node']->type == 'DVD' && $build['#view_mode']=='teaser'){
    $build['links']['node']['#links']['node-readmore']['title'] = t('New Title');
    unset($build['links']['comment']['#links']['comment-add']);
  }

}
-1

In a view admin page (/admin/structure/views/view/your_view/edit/display_id), you should have access to the Pager setting. In D7, this is in the middle column under Block Settings, Header, and Footer.

It's called "More Link". You can toggle that off/on per display and once it's on, you can then customize the text. Doesn't appear to use tokens, though, so might not help if you wanted something more dynamic.

4
  • That "More Link" is a per-display, not a per-item one.
    – jamix
    Commented Jun 16, 2014 at 13:01
  • I must have misunderstood your question. I thought you wanted to remove it completely.
    – Nels
    Commented Jun 17, 2014 at 0:44
  • i'm trying to click 'this answer is useful' but it won't let me
    – TopTomato
    Commented Jun 18, 2014 at 1:52
  • No worries. There are multiple ways to do most things in Drupal. If your view is returning fields, you could add your custom Read More there through a Global:Text field and some re-writing. If your view is returning nodes, you could use Display Suite and it's build modes. The answer @Wolverine provided is good because it you can catch any Read More link and have it display as you want without install a module that potentially delivers much more than you need. edit: I can't actually up-vote Wolverine's answer because I'm new-ish on the site and don't have enough Rep yet.
    – Nels
    Commented Jun 18, 2014 at 1:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.