2

I've filed a support request on drupal.org about this question, but I figured I should ask here as well because someone could know the answer.

I want to change the "Read more" link in teasers so that it says "Full story". I was pointed to the String Overrides module which supposedly makes it very simple to change the built-in strings. The UI isn't very complicated, so I'm not sure what I could possibly be doing wrong, but it's not working. I have saved the settings, flushed all caches, etc.

Do you have any idea?

enter image description here

7
  • Is this for a custom theme? The 'Read more' link might not be going through the t() function which I believe is required.
    – enzipher
    Nov 17 '12 at 0:24
  • It is a Zen theme. I have grep'd through the entire Zen theme directory for the string "Read" and "Read more" and it isn't found, so it doesn't look like the theme is setting this value. Nov 17 '12 at 0:54
  • And you are sure it's not simply a letter case issue?
    – enzipher
    Nov 17 '12 at 1:15
  • I thought that too, but I've copied and pasted the text to make sure. Nov 17 '12 at 1:40
  • It works with other strings. I've tried replacing strings in the Admin UI and it works there... but just not with the "Read more" link and I can't figure out why. I've searched the entire codebase and tried replacing EVERYTHING that said "Read more" but haven't found anything which changes it. Nov 17 '12 at 1:44
4

Might need some tweaking, but you can change the text in hook_preprocess_node(). If you set it to "Read more" you can override it with stringoverrides after, or change it to what you want at once.

In your themes template.php, add:

/**
 * Implements hook_preprocess_node().
 */
function MYTHEME_process_node(&$vars) {
  // Change default text of the read more link.
  if (isset($vars['links']['node']['#links']['node-readmore'])) {
    $vars['links']['node']['#links']['node-readmore']['title'] = t('Read more');
  }
}


Related modules:
http://drupal.org/project/readmorecontrol
http://drupal.org/project/read_more
http://drupal.org/project/linkoutreadmore

2

After many hours of fighting with this, I found the source of the problem.

I believe this to be an issue in core (not really a bug, per se). In the node.module, when it is building the "Read more" link in the teaser view, it has this code in node_build_content():

'title' => t('Read more<span class="element-invisible"> about @title</span>', array('@title' => $node_title_stripped)),

So when Strings Override is doing string comparison it isn't matching, because "Read more" is obviously not the same as "Read more<span class="element-invisible"> about My Title</span>".

I edited the node.module so isolate the "Read more" text from the rest of the HTML like so:

'title' => t('Read more').t('<span class="element-invisible"> about @title</span>', array('@title' => $node_title_stripped)),

Then the system is rendering two strings: "Read more" and "<span class="element-invisible"> about My Title</span>."

2
  • Interesting. Thanks for sharing your findings. Although I would not recommend to hack the core files. You should be able to override the output in your theme which would be a more long lasting solution.
    – enzipher
    Nov 17 '12 at 2:40
  • I looked and looked for some hook that would allow me to override that in my theme template... but couldn't find anything. That's why the issue of changing the "Read more" text is such a popularly asked question for Drupal. Do you know what theme hook I can use? Nov 17 '12 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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