0

There are some related questions but they are not very new, and I'm not sure if I get it right. My question seems quite elementary.

Am I wrong in assuming the following basic fact? In the standard default installation of Drupal 7, all articles show a "read more" link, even if there is actually no more text to show. And there is no simple way of changing that stupid behaviour.

Please, tell me that I'm wrong.

2 Answers 2

2

No, and yes - sort of, in order.

The teaser system assumes that there will always be more to read so if you choose to show the teaser, by default it will always have a 'read more' link.

You can, however turn off the link entirely quite easily. Copy node.tpl.php from your main theme into your custom theme directory and comment out this part:

<?php print render($content['links']); ?>

If you only want to show a read-more link when there is more to read, you almost certainly need to build a custom module for that. There's lots of good documentation on how to do that, but we can probably help with the specifics here once you have a framework going if that's what you decide to do.

Note that if you only want to change the behaviour for a particular content type, put some logic around the line instead of commenting it out, like this:

<?php if ($node->type != 'article'): ?>
  <?php print render($content['links']); ?>
<?php endif; ?>
2

depending on the level of control you need, you could try the Read More Control module:

A module to control when the teaser Read More link appears in Drupal 7.

There is no mechanism in core to decide if the read more link should appear. This means that this link will always show no matter if there is additional content to display. This module tries to overcome this issue by allowing administrators to determine how to handle this link in relation to both the content type and individual fields.

The module allows you to add Read more links to other supported view modes (RSS feed, Search results, etc) or even other supported entity types. Particularly useful if you use panels or views and either programmatically add additional view modes or use other contrib modules to provide these.

3
  • Oh! Useful, much better than my answer.
    – Darvanen
    Commented Sep 19, 2014 at 1:44
  • Thanks. It still surprises me (perhaps I'm missing something?) that a module is needed, I'd say that that behaviour (show the "read more" link ONLY when there is more text) is totally expected/desired/standard in any blog/CMS.
    – leonbloy
    Commented Sep 19, 2014 at 19:06
  • it's a performance issue - by showing it all the time, the system doesn't need to check the length of the content against a defined standard to decide whether or not the read more is required, plus there may be options available only when viewing the full node rather than a teaser, even if the text itself is displayed complete in the teaser.
    – Geoff
    Commented Sep 19, 2014 at 19:19

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.