Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Sorry if someone has already posted a support request about this but I was not able to find something about it.
When I modify the teaser code output, I have no "read more" way to show the rest of the post from the main page: I want to know if it is possible to have a way to call the "read more" feature with link to full-article with an image "a href whatit is" image "/a".
Thx a lot
Comment | File | Size | Author |
---|---|---|---|
#5 | contemplate_read_more_patch_5.x-1.8.patch | 522 bytes | selmanj |
Comments
Comment #1
bdornbush CreditAttribution: bdornbush commentedIf there is a long enough body to generate a trimmed version, the "read more" link will appear.
But what if there is not enough? I inserted the following into the Teaser Template. It will always generate a "read more..." link to the full node.
<a href="<?php print $base_path ?>/?q=node/<?php print $nid ?>">Read more...</a>
Of course, now I have two read more links in some cases. I changed it to
<?php if (!$node->readmore) {?><a href="<?php print $base_path ?>/?q=node/<?php print $nid ?>">Read more...</a><?php } ?>
and now my read more link appears only if the other read more link doesn't appear.
Comment #2
gareth_w CreditAttribution: gareth_w commentedThanks for the snippet, it's similar to what I have but more elegant.
My issue is that if I use this it redirects to /mysite/node/99 which is fine, but if my node has a URL set (e.g. /mysite/node/my_page) this is not displayed, and I would rather this (name) was bookmarked rather than the node/nid reference.
Do you know if a work-around for this is possible?
Thanks,
Gareth
Comment #3
joel_guesclin CreditAttribution: joel_guesclin commentedVery late response - but personally I would use the Excerpt module which allows you to customise what you put in the Teaser
Comment #4
mikemccaffreyTry this:
It will translate the node/id into whatever pathalias is set. All the extra arguments passed to the link function is to enable the last flag which lets you use html. You can't use $node->path due to a permissions bug for anonymous users.
Comment #5
selmanj CreditAttribution: selmanj commentedI didn't like having my Read More link be separate from the other links relating to a node.
Here's my (not so great) solution. If a content type has the teaser output overridden within contemplate, display the read more link. This isn't the best solution since someone might be generating a teaser identical to the body, but I think it covers most users. I couldn't think of a better way of doing it, since the readmore flag has to be decided early-on in the node loading process. Hopefully someone better with CCK/contemplate can figure out a more appropriate solution.
See the attached patch for contemplate-5.x-1.8.
Comment #6
selmanj CreditAttribution: selmanj commentedComment #7
jrglasgow CreditAttribution: jrglasgow commentedI don't see the point in the patch, There isn't a problem that I see with the way contemplate handles the 'Read More' display. You shouldn't need to patch the module to achieve this. I would use bdornbush's solution to solve this problem. If you see a problem where contemplate is stopping the 'Read more' from appearing when there is enough content to justify it I will look into applying this patch, or orchestrating my own solution to fix it.
Comment #8
gagarine CreditAttribution: gagarine commentedA read more link for contemplate, work with alias and clean url enabled or not:
Comment #9
KarimB CreditAttribution: KarimB commentedTry this one with the variable $node_url