Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
By nautis on
I would like to add the "read more" text into a line after the teaser, left aligned, rather than right aligned and in the body rather than below it. It gets lost on a list of: posted in..., print this page, add new comment, read more.
I couldn't even find the code for the read more link. Does anyone know where it is?
Comments
Yes!
I second the motion. Particularly with unsophisticated users, the 'read more' text is often not seen, with the result that they think there is no more to the post than what is in front of them.
I cant think of any reason why this would not be an easy change, but i don't even know where to begin looking for the code, nor what to do when I find it.
Sorry. Let's hope someone else more knowledgeable comes along.
I second that
I'd like to see the read more there also. And I'd like put all the other links in a block. Actually, I'd like them in a block near the title of the content, not within a regular block, but am not quite sure how to go about this.
Same problem here. Would be
Same problem here. Would be great to place the 'read more' link next to the teaser. People simply miss it when it is placed at the end of the Posted in links.
Here's how to do it in a PHPTemplate theme
Is this what you're looking for?
Grab the FriendsLight theme and take a look at the node.tpl.php file. This part of the code is what you want:
As you can see, it is a bit messy, but it works very well, in 4.5.2 anyway. Haven't tested it with 4.6 yet.
I think I got this code from some other PHPTemplate theme, but I don't remember which one. My apology to the original author for not giving credit here!
thanks
That worked well thanks.
All I can say is awesome;
All I can say is Awesome; thank you. This code needs to get into the handbook.
: z
Geary,
Geary,
Sweet. That's it exactly. I'm going to try to make these changes to 4.6. Thanks for your help.
Update: I tried in 4.6 and got this error: Call to undefined function: link_node()
Does anyone know where I should define this function? I looked in the FriendsLight template.php but there was no reference.
- Matthew
Sigh
Alas, this no longer works in 4.6.
: z
This might work in 4.6
I haven't tested this in 4.6 yet, but I took a look at the difference between 4.5.2 and 4.6, and it looks like this might do the trick. Change this line of code:
to:
So the whole thing would be:
I'll test this when I get a chance, but in the meantime if anyone would like to try it and report back, I'd be curious to know if it works. Thanks!
We have lift off
Thank you Geary, that did it perfectly.
: z
thank you!
Thank you so much for this! You're my Lifesaver of the Day! (You can pick whatever flavor you are!)
silverwing
www.misguidedthoughts.com
not working
probably I'm doing something wrong, but this isn't working on the site I'm setting up (opus.org.au). basically it changed nothing. it still looks like it did before. I've added the code to the node.tpl.php file (in place of the content div), and re-uploaded it.
I'm using the green slash theme (http://drupal.org/project/slash), so I'm wondering if maybe the theme is calling a different function... I wouldn't know, I'm not a php coder.
Is it the PHPTemplate version?
There is a PHPTemplate version of Slash in CVS. Are you using that version or the older one which didn't use PHPTemplate? This patch is for PHPTemplate themes only. Try the CVS version of Slash if that's the problem.
yes..
yeah, you're right.. I'm not confident using CVS though (I never have, infact). perhaps I'll just wait until the downloadable version comes out..
ned
even so..
I downloaded the http://drupal.org/files/projects/slash-cvs.tar.gz
most of the files in that are reasonably up to date (most jan 2006)
is that still not a PHPtemplate theme? is there any way to tell?
ned
It is
That theme has files named page.tpl.php, node.tpl.php, etc. Those are PHPTemplate files.
worked with small modification
I tried Geary's code to move the 'read more' link and only got it to work after I made a small modification. I am using Drupal 4.6 and the Friends Electric theme with Clean URLs disabled.
When I tried the code provided by Geary, the 'read more' link ended up pointing to:
When it should have been pointing to :
I changed $node_url to node/$node->nid and then it worked. Like this:
I don't know why, but it works.
Thank
the code worked well with no problem, thanks.
-----
www.PersiaData.com
Does this work for all
Does this work for all phptemplate themes (4.5)?
I am using Democratica and the code on node.tpl.php looks very different:
Being a newbie, I am stumped where to include your code. I would be thankful for some suggestions.
One more issue with 'read
One more issue with 'read more'. If you have set the minimum words to 0 and don't use a delimiter, you will get the 'read more' link even if the full text of the post is already there.
Update: Well, you will get the 'read more' link even if you set the minimum words to 10 or something.
By design, no ?
I think it's by design, because some module can add content that would not appear in the teaser.
For example : trackbacks & comments are only visible in the "full view" of a node.
Oh, I didn't realise that.
Oh, I didn't realise that. Thank you.
Can you do it anyway?
I realize that comments and trackbacks may have more information than the original node and therefore if additional information exists, the read more link is appropriate. However, for nodes that have these disabled or for nodes that have not been commented on, the ability to remove the read more link would be useful.
Does anyone know how to either:
Thanks
how to do this in an xtemplate theme?
Where do I tweak the 'read more' link in an xtemplate theme?
Thanks.
Here's an xtemplate propsal; is this a more-general solution?
The following represent changes I made to drupal.4.6.1:themes/engines/xtemplate/xtemplate.engine to implement a "Read More" in the way that I prefer for my site.
I'm relatively new to Drupal, so I ask: is this not a more-general solution then changing a specific theme (like the methods above appear to do)? Therefore, would it not be preferred in order to make it work for any theme or any other site/sheet style?
My modified drupal.4.6.1:themes/engines/xtemplate/xtemplate.engine:
-Matt
matt -
matt -
very cool. this should work for xemplate 4.5:
Read More Link...this is really too difficult
I know I'll probably catch hell from the but it's so flexible crowd, but this is a good example of what (I feel) Drupal will have to overcome to really get popular in the mainstream.
I'm a Drupal newbie, but have been around CSS, and PHP for some time now. All I wanted to do is to get the "Read More" link to show up on a line of it's own just under the body of the post.
I'm using 'FriendsElectric', and looked at all of the tpl.php file, the style sheet and the template file...I could not find a reference to 'Read More' anywhere there?? Am I blind? Should this be this difficult?
Mark
node.tpl.php
Line 20. It's called $links
http://drupal.org/node/11816
What name would you have called it?
-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide
Thanks
I appreciate the help. Now that I've found it can I ask a new question? Where is the content of $links defined? What I want to do is to separate the "Read More" portion, and be able to move it to the top of the section, and make it stand out?
Mark
re: too difficult
Yeah, I find this discouraging too. Much as I like the functionality of a Drupal site, I dread the propect of modifying anything behind the scenes.
As a ColdFusion developer, I'm used to being able to dig into any application and easily modify the presentation HTML. As long as you don't muck up the special CF tags which insert database results, any HTML jockey can customize the template layout til the cows come home with nothing more than HTML and CSS knowledge. Something like repositioning a "read more" link would be no more difficult on a CF template than on a static HTML page.
I know PHP is a different beast, but I sure wish that the content and presentation weren't so intertwined in complex scripting.
Not working consistently
My "read more" stuff is not working consistently. Most all the content has gotten consistently "truncated" in the teaser until recently. Now I'm finding some blog posts get truncated at different character-number points, others don't get truncated at all. I see not consistent pattern for the different behavior; seemingly randmon at this point.
Anybody have any ideas?
I'm running 4.6.1.
-Matt
Anyone know how you remove
Anyone know how you remove it completely?
expand
What are you asking? You can change teaser length per node type. I think this is in input formats (make it long if you don;t want teasers). If you mean the Read More link itself? That depends on the theme you are using.
-sp
---------
Test sites and good habits: Drupal Best Practices Guide.
Misc Black Mountain
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide
I mean the Read More link
I mean the Read More link itself. I want it gone. I'm using Bluemarine if that helps.
handbook
Look here for xtemplate theme based instructions.
http://drupal.org/node/6493
Looks like you will want to play with line 87 but I am not entirely sure of the effects. I tend to use phpTemplate based themes.
-sp
---------
Test sites and good habits: Drupal Best Practices Guide.
Misc Black Mountain
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide
re: Here's an xtemplate propsal; is this a more-general solution
I agree that this method seems to make more sense and it does work on my site. However, is there a way to get the "read more" so it appears just after the teaser instead of a few lines down??
I really hope 4.7 has an easy way to deal with this.
Thanks,
Aaron
http://www.thesourceshow.org
Thanks!
Thanks, Matt, it works perfectly! I would'nt be able to do it....
I know I'll probably catch
I know I'll probably catch hell from the but it's so flexible crowd, but this is a good example of what (I feel) Drupal will have to overcome to really get popular in the mainstream.
I'm a Drupal newbie, but have been around CSS, and PHP for some time now. All I wanted to do is to get the "Read More" link to show up on a line of it's own just under the body of the post.
I'm using 'FriendsElectric', and looked at all of the tpl.php file, the style sheet and the template file...I could not find a reference to 'Read More' anywhere there?? Am I blind? Should this be this difficult?
Mark
FriendsLight has this
It sounds like you're looking for what I implemented in the FriendsLight theme:
http://drupal.mg.to/
FriendsLight is closely based on FriendsElectric, so if you diff the two you will find the code it uses. I described it earlier in this thread, but I think I updated the theme after that to fix some other problems, so grab the latest here:
http://drupal.mg.to/2005/05/14/friendslight-theme-updated-for-drupal-4-6
Great Thread guys!
Thanks guys for the info...
I actually asked myself the same question nautis asked in April (its now September?!)
And thanks to Geary for the info too!
---------------------------------------------------------
My Blog - Photography, travelling and University...
Its me again
I've just come to report that this "hack" is having some weird effects with the image.module and comments
---------------------------------------------------------
My Blog - Photography, travelling and University...
Here's my solution
Twofold approach. See it in effect at http://thetrents.org
1) I edited the CSS in my theme to make the "read more" link both bright green and larger in size (and therefore more noticeable).
2) I changed the way teasers are created when you post content. Now it adds a "...CONTINUED..." line at the end of any content that's chopped. Patch to node.module is below:
one solution, and some thoughts.
personally i think the break link should be put into $content, so that it shows up in rss feeds (currently on most feeds it just looks like the entry abruptly ends, confusing folks quite a bit i imagine.)
considering this is part of a core module, a hook_readmore($message) might be nice to set a custom message, place an image instead if desired, etc?
what i wound up doing for now...well, it's a total hack since it involves commenting out a few lines in a module, but, for a phpTemplate solution...
in node.module, around line 635 or so, you should see:
comment that out, then, create a node.tpl.php if you don't already have one. wherever you want your "read more" link, paste this in:
that should do it.
Read more link placement
Using the code provided here (with a tip-of-the-cap to Geary), I was unable to drop-in any of the code snippets with my theme (which is a hack of the chameleon theme).
This snippet works with drupal 4.6.5 (and I imagine the whole 4.6 series).
good idea
I reckon you're on to something. I'd even prefer it to be on the same line as the teaser. it's in a different colour, cause it's a link anyway so it'd be kind of obvious.
I'd also like to be able to remove the "add comment" link from the teaser. I don't want people commenting on the teaser, but on the actual page.
remove the "add comment" link
I agree - if a node is long enough to split to a teaser and a "read more" page, I'd like people to see the full page before commenting.
I don't like mucking about with code though. I wonder if someone could create a module to control placement of node links? ;-)
Removing the "add comment" link
Now that's a fine idea :)
Do excuse the hack 'n slash directness of the solution (and the mucking through code ;-)
Making the "add comment" link not show up on teasers is fairly easily achieved. This snippet relies on the snippet posted earlier.
Voila! Now your users can't add comments to articles with teasers from the mainpage.
Option to not allow the add comment option if read more.
http://drupal.org/node/58050
petermoulding.com/web_architect
petermoulding.com/web_architect
YALS
Yet Another Links Solution.
I've posted it elsewhere as well, but thought I might share here. This works for 4.7beta2.
Background $node-> links is an array with all links:
Depending on the number of nodelinks read more may be in 0 or 1 (or ?).
Goal is to convert the array to
But in a way that makes it also work in a translation.
In node.tpl.php (or combine with http://drupal.org/node/16383)
(edit: $node->links is not always set, added isset())
Then when I'm ready to print the read more links:
You may beautify the printing with some divs/spans
The rest of the links can be printed in more or less the same way, a foreach loop or a simple:
Possible drawbacks: with implode, links may not always be drawn in the same order. Other point 'add new comment' changes to 'n comments' when there are comments.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
Works great. Thank you :)
Works great. Thank you :)
Work greates! But how do the
Work greates! But how do the same for "user's bolg" link?
This works great thanks, one favor
How would I use this method to display the "# of reads" in a different area?
I tried
But that dont work, any help would be greatly appreciated.
Feeds
Something else I've just noticed, when viewing my RSS feed, is that you do want the teaser itself to reflect that there's more to the article, because that'll show up in your feed. A method like the one I posted earlier in this thread accomplishes that.
Working in 4.7?
Has anyone figured out how to accomplish this in 4.7?
I'd like the "Read More" link to appear right after the last word in the teaser, not in the Links area.
I'd love to see some code on this...
Patch for 4.7
Here's a patch for a recent CVS pull of 4.7. I also make the "read more" link bigger and bright green in my CSS (http://thetrents.org/).
--- node.module 2006-03-09 14:38:40.000000000 -0800
+++ node.module 2006-03-26 18:06:53.000000000 -0800
@@ -172,7 +172,7 @@
// If a valid delimiter has been specified, use it to chop of the teaser.
if ($delimiter !== FALSE) {
- return substr($body, 0, $delimiter);
+ return substr($body, 0, $delimiter) . " ...CONTINUED...";
}
// If we have a short body, the entire body is the teaser.
@@ -187,12 +187,12 @@
$breakpoints = array('
' => 4, '
' => 0, '
' => 0, "\n" => 0, '. ' => 1, '! ' => 1, '? ' => 1, '。' => 1, '؟ ' => 1);
foreach ($breakpoints as $point => $charnum) {
if ($length = strpos($body, $point, $size)) {
- return substr($body, 0, $length + $charnum);
+ return substr($body, 0, $length + $charnum) . " ...CONTINUED...";
}
}
// If all else fails, we simply truncate the string.
- return truncate_utf8($body, $size);
+ return truncate_utf8($body, $size) . " ...CONTINUED...";
}
function _node_names($op = '', $node = NULL) {
"Read More" Placement
How can I remove the "» read more" link from the front page?
Thanks, Darly
Apache is bandwidth limited, PHP is CPU limited, and MySQL is memory limited.
Do it in CSS
Depending how your frontpage is setup (this matters because you might end up removing "Read More" from any page it would normally appear on) look at your css and figure out what the div tag is for read more. FireFox's web developer tools are great for this. Usually it is called
to your stylesheet. If you just want the full content on the front page than change your settings so a very high number of characters are allowed on the frontpage under mysite.com/admin/node/configure or add
at the bottom of your post.
Do it in CSS
Thanks, works great!
Apache is bandwidth limited, PHP is CPU limited, and MySQL is memory limited.
Hrmm, I'm trying to raise my
Hrmm, I'm trying to raise my character cap high, but I can't seem to find the area. When I go to mysite.com/admin/node/configure it just shows the Manage Content displaying all of my posts?
I get the headline "Settings for the core of Drupal. Almost everything is a node so these settings will affect most of the site." but nothing different from the admin/node page
Which one of all these options work in 4.7.2?
I want the read more link at the end of the body text and the rest of the links in a block. Teasers should
have the commenting link removed so readers only can comment on the whole post.
I'm pretty bad at modifying modules etc, so anyone who answers, please write what goes where as that isn't very clear in the options describes above.
Thanks in advance!
/ Ayza
P.S. Maybe this hack should go into the handbook instead in a more structured way?
http://drupal.org/node/58050
http://drupal.org/node/58050 is working in a 4.7.2 site and makes the comment an administration option.
petermoulding.com/web_architect
petermoulding.com/web_architect
Where do I put it?
Thanks, Peter, for your reply.
However, I have no idea where to put the code. I've looked through the files that seem relevant and the only I can find that seem to match somehow is the template.php file in my theme directory. However, since a patch seemed necessary, I got the feeling it was a core function.
Please tell me what goes where!
Thanks again,
Ayza
modules/comment.module
comment_configure() is about line 350 in modules/comment.module
comment_link() is about line 180 in modules/comment.module
petermoulding.com/web_architect
petermoulding.com/web_architect
Thank you!
Btw, do you know if there is anyway to put an extra comment link on the page, say if I want one in a block but also one at the end of a post?
How should the PHP snippet read?
Different read more style
I'd like to add "...read more" to the end of each teaser, and then below that where the links normally are, show this instead (aligned to the right as usual):
Submitted by username on Mon, 2006-07-10 21:39
[catigory1/catigory2/catigory3]
5.1???
Would anybody well versed in the code care to go through and ensure this still works properly in 5.1. I'm right now as I'm writing this about to try to use it in 5.1 I'll post an update as to what I got when I'm done. However, in the meantime it might be helpful to me and everyone else if someone would run through the correct coding to be used in 5.1
In Drupal 5.x : adding a inline readmore link
Adding an inline read more link in Drupal
Caroline
A coder's guide to file download in Drupal
Who am I | Where are we
11 heavens
This imply to hack the core...
... which is not a very clean/drupalish way of doing.
Read the post from merlinofchaos The nuisance of the Read More flag and his comment
Merlin Made a Module
for 4.x and 5.x
http://drupal.org/project/ed_readmore
sweet!
It took me like ten minutes, searching, refining the search, going through this thread, going to angrydonuts before I found it, and it hilites a frustration I've been having with drupal.org ... many search results go to long, long, no longer active threads from before 4.7 or 5.x and contain reams of code, disputed code, or irrelevant code to problems that now have either a.)different solutions in 5.x or b.)a module.
I wonder if there's some way to give weight to more recent or relevant results in searches (modules before threads?), or to archive older threads, or something. It's definitely a problem, and will get even worse as the years go on and we move to 6.x, 7.x etc.
Maybe at the release of 6.x just starting the forums fresh and creating olddrupal.org or somesuch as an archive should be considered?
Of course, this rant is at the end of one of those long, old, outdated threads, so it probably won't really get read, but it feels good to vent.
Rafael
http://mediaisland.org
=-=
Using the advance search would allow you to search just for modules or projects or project pages.
Help with Read More ...
Hello to everybody, I am completely new with Drupal. I need to put a "Read more... "on my main page as I will be posting some news...
What steps should I follow to make this work? I have seen in this forum some code on a template.PHP file, but I really don't know what file this is, where it is and how to do it. Can someone please tell me how to do this? (step by step). Thanks.
=-=
you don't need code to do this anymore, there is a module available, ed_readmore in the downloads area. linked in this comment : http://drupal.org/node/21538#comment-237215
Placing "read more" before "add comment"
What if I simply want to place "read more" before "add comment" in the links section? Is there a configuration for this somewhere? I see the "first" and "last" tags in CSS but don't know where to change those...
Solution
Just found a way to do it for anyone interested. In your theme's stylesheet:
Alex
----------
Contract Web Development, Inc.
Browser Compatibility
To keep the links aligned horizontally in IE 6-, you need to define list elements:
Alex
----------
Contract Web Development, Inc.
just in case it is still of
just in case it is still of interest: I was recently digging through the $links and the $taxonomy and found a way to cut-out whatever from within the links-array:
http://drupal.org/node/115920#comment-273091
..hope it's not too confusing - worked fine for me..:]
greetz, t..
___________________________
my pictures: www.bilderbook.org
___________________________
good topic
subscribing!
WAI AA fix Read More title to be unique
See also WAI AA fix Read More title to be unique: http://drupal.org/node/174993
petermoulding.com/web_architect
petermoulding.com/web_architect
I know this thread is old,
I know this thread is old, but this is issue is much improved in D7 with granular rendering. http://drupal.org/update/themes/6/7#granular
--
David Needham
Team Lead of Training at Datadog