Closed (fixed)
Project:
Read More Link (Drupal 6 and earlier)
Version:
6.x-5.0-rc5
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
11 Nov 2009 at 18:01 UTC
Updated:
4 Dec 2009 at 22:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
todd nienkerk commentedYes, this sounds like a bug. I'll look into it.
Comment #2
brianmercer commentedSame here since rc3. Thanks.
Comment #3
todd nienkerk commentedFixed in 6.x-5.0-RC4.
Comment #4
mcjim commented6.x.5.0-RC4 is not working for me, I'm afraid. Placing the link mid-paragraph. Brain currently too addled to work out why, it's been a long day :-)
So I went back to the previous preg_match and took out the 'm' flag. That works, though I don't know if it has any consequences.
preg_match('!(</?'. $elements .'[^>]*>)+s*$!i', $teaser, $match, PREG_OFFSET_CAPTURE)Comment #5
todd nienkerk commentedmcjim: Can you verify that you are indeed running 6.x-5.0-RC4? The regex you pasted in is from RC3, which makes me think you're running an old version. The line should read:
Comment #6
geerlingguy commentedI'm running RC4 and can confirm that the update has fixed the issue. See: http://stlouisreview.com/taxonomy/term/34
Comment #7
WildBill commentedYes, I had this issue with RC3, but RC4 appears to have fixed it.
Comment #8
Thoor commentedSame Problem to me ... definetely running 6.x-5.0-RC4, but the read more link is not "inline" ... its a DIV around it!
i.e.:
Comment #9
gregarios commentedThis is fixed as of rc4. Verfied. Works great now! Thanks!
Comment #10
gregarios commentedCheck out the new settings if you're upgrding from earlier point-releases.
Comment #11
mcjim commentedYes, RC4. Apologies if I wasn't very clear last night.
I commented out the new regex (line 207) and uncommented the old (line 213) to which I made that modification (removing the 'm' flag).
On a clean install of Drupal, I can create some content with devel and it works fine.
On a site I'm currently working on, however, I'm getting this:
Which is bizarre, to say the least.
In this scenario, this is what fixes it:
if (preg_match('!]*>$!i', $node->content['body']['#value'], $match, PREG_OFFSET_CAPTURE)) {
I'll look into this more today.
UPDATE: Messed up the copy/paste on that.
This is what works:
Comment #12
mcjim commentedOK, I've already looked into this (the kids had to wait for breakfast) and found the cause.
On a clean install of Drupal, I enabled devel and ed_readmore and RC4 worked as expected.
I then enabled CCK and added a text field, keeping everything at the defaults, edited a couple of posts and *still* all was expected.
However, as soon as I moved this CCK field above the body (using drag n' drop on the Manage Fields tab for that content type) then the bizarre behaviour occurred, with the Read more link appearing mid-content.
Making the change outlined in the previous comment fixes this behaviour, though I've only tested it as far as "it works for me".
Comment #13
gregarios commentedOOPS! It looks like this is still happening sometimes, in very strange ways... Sometimes the readmore link is inserted into a sentence where there are no tags at all. There are even drupal teaser breaks placed at the end of where you see these teasers end... See attachment:
Comment #14
todd nienkerk commented@mcjim: Here's what I think is happening.
The Read More link is inserted into the teaser by counting the number of characters prior to the final closing element (usually a
</p>). When CCK fields are added before the node teaser, that character count is now wrong, and the link is inserted into a spot that seems random.Example:
Here, the Read More link is inserted after character 48, which is the spot just before
</p>. When you add a CCK field to the beginning of the output:...The Read More link will be inserted roughly after the word "It's," which lies at the 48-character mark.
CCK support is going to be a tough nut to crack, as I hadn't considered the implications of adding CCK output to the beginning of a node.
Comment #15
todd nienkerk commented@gregarios: I think my explanation above applies to your situation, too. Note that in the screenshot you attached, the only node showing improper Read More link output is one with a subtitle. I assume this is a CCK field that's being displayed at the top of the teaser?
Comment #16
gregarios commentedYes, you're right. Every article I have with a CCK field above the teaser is affected. WHY is there such a problem now when there wasn't in the previous point release?
Also, I have my CCK field placed via the node.tpl.php file, but it is also at the top of the teaser. The field at the top of the teaser is suppressed using CSS.
Maybe, you can have an option to include or exclude CCK in the settings. Including it would allow the calculation as is, while excluding would remove the length of any
div class="field"from the teaser.Comment #17
gregarios commentedOk, I just had a "DUH" moment, and turned off the display of the CCK by excluding it from the teaser and node body. I assumed this would have removed it even from the subheadline spot I placed in the theme file, but it didn't. I would have turned it off long ago instead of blocking it via CSS. So, now that I turned it off in the Content Type CCK Display settings, the readmore link is always in the right spot.
So, temporary workaround: Place your CCK fields using theme files, and not the Content Type CSS settings.
Comment #18
djs_core commentedI have the same problem! See here: http://www.djscore.org/ Read More link is not inline at end of node body :( Any idea ?
(version 5.0 rc4)
Comment #19
gregarios commentedTry changing your settings to have the readmore link attached to the
<p>tag instead of<div>.Comment #20
djs_core commentedIn the setting is selected:
<p>...Comment #21
djs_core commentedsee attached image ;)
Comment #22
mcjim commentedRegarding CCK:
How about adding the readmore link in hook_nodeapi() instead of template_preprocess_node() ?
I just tried moving the code from ed_readmore_preprocess_node into a ed_readmore_nodeapi function and calling it when $op == 'view'.
Works, unless of course you want the "Read more" after CCK fields...
(Please excuse the scrappy code: for illustration purposes only.)
Comment #23
geerlingguy commentedI'm now having the same problem on one of my sites, when I have an imagefield set to display above the body field.
Comment #24
Shai commented@geerlingguy,
Exactly the same problem for me, beginning with RC4.
Shai
Comment #25
Masterrer commentedSame here using 5.0 rc4
Comment #26
bcobin commentedSame problem with imagefield on rc5; falling back to rc2 is the temporary (I hope!) workaround.
Below is the malformed output as it appears on the screen - hope this helps!
read more »t-impact-2009-lighting-base-pyramid-osram-energy-hubs" class="imagecache imagecache-ic_teaser imagecache-linked imagecache-ic_teaser_linked">Comment #27
choster commentedMoving CCK fields below the body and rearranging their display in the theme is a suitable workaround only if you also re-theme the input forms. We had moved "author" and "publication date" above the body because that is the logical place where our business users would expect to enter that content.
Comment #28
sylvain_a commentedsuscribe
Currently not working with RC4 version.
Comment #29
todd nienkerk commentedAll: Please see my explanation in #14 above. I'm fairly certain I've nailed the cause, so unless you find that I'm wrong, we can all save some time by ending the speculation until I can look into this further.
Comment #30
todd nienkerk commentedSwitching to normal priority because lack of CCK support isn't a show-stopper.
Comment #31
mcjim commentedWell, there's one or two sites that use CCK... :)
Anyway, do you think it's worth investigating my proposal in #22?
Happy to work on it and supply a patch: just don't to waste time if there's some good reason using hook_nodeapi is not a good idea in this scenario.
Comment #32
Shai commentedTodd, I think the reason why people might seem a little intense about this is that RC3 broke what was working in RC2. I didn't even know that ed_readmore didn't support CCK because I didn't have a problem using it in conjunction with CCK.
My situation... I've got a filefield/image widget that is set to display a thumb in a teaser. I've got ed_readmore set to display "Read more" inline at the end of the teaser. It worked fine in RC2. It doesn't work in newer versions.
Maybe it shouldn't have worked fine without explicit CCK support in RC2, but it did for me and for many others.
So if you were able to understand and explain why it was working and what is breaking it, that would be awesome.
Reverting to a previous version was easy because there are no db tables associated with it. So I don't feel urgent about it and I'm fine with a priority of "normal." But I don't want to be stuck at RC2 forever cause this is such a good module and I want to grow with it.
Thanks for all your hard work.
best,
Shai
Comment #33
todd nienkerk commentedAll: The difference between RC2 and RC4 is the use of
$teaser(RC2) versus$node->content['body']['#value'](RC4). This change is outlined in comment #13 of this issue: #297010: Inline placement of read more link in teaser with CCK fieldsIn RC2 (and all previous versions), the Read More link was being inserted after all CCK fields on a separate line. In RC4, the link is appended to the node body before all CCK fields. However, the fix in RC4 didn't account for CCK fields being added above the node body, which is the problem being discussed in this issue.
We'll need to answer two questions:
hook_nodeapi()ortemplate_preprocess_node()? (And if it's the latter, should we use$teaseror$node->content['body']['#value']?)Comment #34
kay_v commentedHi Todd -
Thanks for the great module! deserves its spot in Lullabot's latest top 40 list (wish I'd known about it even earlier).
It may be worth making RC2 the version recommended for D6 while the issues with CCK are addressed. The effect of the error escaped me for over 24 hrs before it was pointed out by a few irate visitors ;-) - took a bit of time to track down the cause, and I felt lucky when I finally came across Shai's helpful posting #32 above.
FWIW as a suggestion. And kudos again!
Kay
Comment #35
Shai commentedQuestion #1. I agree with Todd that it should be in the node body; make CCK fields irrelevant.
This "keep it simple" approach is awesome for D6. However, there is no node body for D7. For D7, how about adding a read_more setting on field creation settings and associate the read more with a particular (or I guess even more than one) field.
Just a clarification of the word "Teaser" here. What Todd means is everything that gets displayed with Teaser as defined on the display fields page of CCK admin. Sometimes people can use "teaser" to mean the "teaser-text" which we are now calling "summary."
And to continue with the disambiguation... Todd when you say "node body", in this situation you mean that the read more will display after the "summary" text or the auto-trimmed body text based on post settings.
I don't have an opinion about question #2.
Shai
Comment #36
todd nienkerk commentedTo address question #2 in my comment #33 above, it appears
hook_nodeapi()is the wrong place to insert the Read More link for one simple reason: Any inserted markup is prone to removal from various input filters. Because the link is wrapped in<span>tags, it will be removed by any HTML input filter that is not set to allowspanelements.Back to
template_preprocess_node()...Comment #37
todd nienkerk commentedOkay! I think I've fixed it. Check out 6.x-5.0-RC5.
Comment #38
choster commentedAwesome, working great for me. Thanks for the quick work.
Comment #39
djs_core commentedFor me still the same as I wrote here -> http://drupal.org/node/629990#comment-2261356
I do not use CCK, views and other, but module not work properly. The Read More link is not after the last word of the teaser. I have in the readmore link settings selected: attach to the
<p>tag, but in the code is generated new tag<div>.Please see here: http://www.djscore.org/
Comment #40
todd nienkerk commenteddjs_core: You have Fivestar installed, which appends stuff to the end of the teaser — specifically, a
<form>element.This is probably a matter of module weight. If you can adjust the weights of the Fivestar and Read More link modules so that Read More happens before Fivestar, the link may be appended between the paragraph and Fivestar form. This is just speculation on my part.
I'm marking this issue fixed because its scope relates only to CCK. If the module weight solution suggested above doesn't work, feel free to open a new issue specific to Fivestar. Please keep in mind, though, that it's not feasible to write workarounds for every module that appends stuff to the teaser.
Comment #41
mcjim commentedTested. Working as expected with multiple CCK fields above and below the teaser.
Good point about hook_nodeapi. I didn't think that through.
Thanks, Todd.
Comment #42
mcjim commentedWhoops. Changed back to fixed.
Comment #43
djs_core commentedTodd Nienkerk: I tried to change the modules weight with util module and nothing happened. I tried the off Fivestar module and the same result. Here I started a new issue -> http://drupal.org/node/638750
See for more information.
Thank you ;)