read more in teaser

parvell - April 18, 2007 - 20:14
Project:Content Templates (Contemplate)
Version:5.x-1.8
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active (needs more info)
Description

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

#1

bdornbush - June 11, 2007 - 00:45

If 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.

#2

gareth_w - August 24, 2007 - 10:45

Thanks 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

#3

joel_guesclin - September 20, 2007 - 12:25

Very late response - but personally I would use the Excerpt module which allows you to customise what you put in the Teaser

#4

mikemccaffrey - October 20, 2007 - 03:08

Try this:

<?php print l("<img src='asdf.jpg'>", "node/".$node->nid, array(), NULL, NULL, FALSE, TRUE); ?>

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.

#5

selmanj - October 30, 2007 - 00:10
Version:5.x-1.1» 5.x-1.8

I 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.

AttachmentSize
contemplate_read_more_patch_5.x-1.8.patch522 bytes

#6

selmanj - October 30, 2007 - 00:15
Status:active» patch (code needs work)

#7

jrglasgow - March 1, 2008 - 20:13
Status:patch (code needs work)» active (needs more info)

I 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.

#8

gagarine - May 28, 2008 - 05:21

A read more link for contemplate, work with alias and clean url enabled or not:

<span class="readmore">» <a href="<?php print url(drupal_get_path_alias('node/'.$node->nid)); ?>">Read more</a></span>

 
 

Drupal is a registered trademark of Dries Buytaert.