The inline readmore link should appear just before the last paragraph-close tag, not the first. The readmore links are appearing after the fist paragraph in the teaser, not after the last paragraph as version 2 did, putting the readmore link inline right in the middle of most of the teasers.

I believe the inline readmore link should appear after the last occurrence of whatever tag is selected in the "Elements eligible for inline placement" selection.

CommentFileSizeAuthor
#39 screen.png80.67 KBdjs_core
#21 screen.png80.67 KBdjs_core
#13 Picture00011.png118.07 KBgregarios

Comments

todd nienkerk’s picture

Assigned: Unassigned » todd nienkerk

Yes, this sounds like a bug. I'll look into it.

brianmercer’s picture

Same here since rc3. Thanks.

Luptatum Uxor Ideo Et
Submitted by Anonymous on Mon, 11/09/2009 - 12:10

node (story) - Quis ea olim. Cui persto dolor tamen tamen natu bene occuro. Comis natu abdo probo utrum proprius velit luctus conventio ludus. Read more »

Facilisi genitus olim verto luptatum. Vel abdo quidem paulatim saepius torqueo minim decet. Commodo antehabeo enim virtus meus. Probo vereor lobortis vereor.

Add new comment

todd nienkerk’s picture

Status: Active » Fixed

Fixed in 6.x-5.0-RC4.

mcjim’s picture

Status: Fixed » Needs work

6.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)

todd nienkerk’s picture

mcjim: 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:

    if (preg_match('!</?'. $elements .'[^>]*>$!i', $node->content['body']['#value'], $match, PREG_OFFSET_CAPTURE)) {
geerlingguy’s picture

I'm running RC4 and can confirm that the update has fixed the issue. See: http://stlouisreview.com/taxonomy/term/34

WildBill’s picture

Yes, I had this issue with RC3, but RC4 appears to have fixed it.

Thoor’s picture

Same 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.:

<div class="content">
<p>Er hörte leise Schritte hinter sich. Das bedeutete nichts Gutes. Wer würde ihm schon folgen, spät in der Nacht und dazu noch in dieser engen Gasse mitten im übel beleumundeten Hafenviertel?</p>
<div class="read-more">
<a title="Kompletten Beitrag: U2 The saints are coming lesen! " href="/community/blog/webpartners/u2-saints-are-coming">Ganzen Beitrag lesen »</a>
</div>
</div>
gregarios’s picture

Status: Needs work » Fixed

This is fixed as of rc4. Verfied. Works great now! Thanks!

gregarios’s picture

Same Problem to me ... definetely running 6.x-5.0-RC4, but the read more link is not "inline" ... its a DIV around it!

Check out the new settings if you're upgrding from earlier point-releases.

mcjim’s picture

Version: 6.x-5.0-rc4 » 6.x-5.0-rc3
Status: Active » Fixed

Yes, 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:

<div class="content">
  <div class="field field-type-text field-field-reference-number">
    <div class="field-label">Ref: </div>
    <div class="field-items">
      <div class="field-item odd"> Kbt9T3ErVhRh </div>
    </div>
  </div>
  <p>node (vacancy) - Importunus minim vindico tation. Odio elit pneum. Cui vereor metuo ea quidem luptatum cam<span class="read-more"><a rel="nofollow" title="Read the whole post" href="/node/11"><strong>Read more »</strong></a></span>ur. Aptent probo odio pagus. Consectetuer cogo cui volutpat uxor decet nostrud. Minim humo humo zelus lucidus quidne nulla minim. Abdo facilisi comis amet ullamcorper. Exerci nimis jus jugis voco. Commoveo mauris cogo nunc erat damnum olim dolus damnum.</p>
</div>

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:

if (preg_match('!(</?'. $elements .'[^>]*>)+s*$!i', $teaser, $match, PREG_OFFSET_CAPTURE)) {
mcjim’s picture

Status: Fixed » Needs work

OK, 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".

gregarios’s picture

Version: 6.x-5.0-rc3 » 6.x-5.0-rc4
Status: Needs work » Active
StatusFileSize
new118.07 KB

OOPS! 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:

todd nienkerk’s picture

@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:

<p>This is my teaser. It's only one paragraph long.</p>

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:

<div>CCK output</div>
<p>This is my teaser. It's only one paragraph long.</p>

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

todd nienkerk’s picture

@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?

gregarios’s picture

Yes, 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.

gregarios’s picture

Ok, 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.

djs_core’s picture

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

gregarios’s picture

I have the same problem! See here: http://www.djscore.org/ Read More link is not inline at end of node body :( Any idea ?

Try changing your settings to have the readmore link attached to the <p> tag instead of <div>.

djs_core’s picture

In the setting is selected: <p> ...

djs_core’s picture

StatusFileSize
new80.67 KB

see attached image ;)

mcjim’s picture

Version: 6.x-5.0-rc3 » 6.x-5.0-rc4
Status: Fixed » Active

Regarding 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.)

<?php
/**
 * Implementation of template_preprocess_node().
 */
function ed_readmore_preprocess_node(&$variables) {
/*  $display = variable_get('ed_readmore_placement', ED_READMORE_PLACEMENT_DEFAULT);

  // Don't do anything if placing the link is disabled
  if ($display != 'disable') {
    // Check to make sure that this is a teaser and there's actually more to read
    if ($variables['teaser'] && $variables['readmore']) {
      $variables['content'] = ed_readmore_link_place($variables['content'], $variables['node'], $display);
    }
  }
*/
}
function ed_readmore_nodeapi(&$node, $op) {
  switch ($op) {
    case 'view':
      $display = variable_get('ed_readmore_placement', ED_READMORE_PLACEMENT_DEFAULT);
      // Don't do anything if placing the link is disabled
      if ($display != 'disable') {
        // Check to make sure that this is a teaser and there's actually more to read
        //if ($variables['teaser'] && $variables['readmore']) {
          $node->content['body']['#value'] = ed_readmore_link_place($node->teaser, $node, $display);
        //}
      }
    break;
  }
}
?>
geerlingguy’s picture

I'm now having the same problem on one of my sites, when I have an imagefield set to display above the body field.

Shai’s picture

@geerlingguy,

I'm now having the same problem on one of my sites, when I have an imagefield set to display above the body field.

Exactly the same problem for me, beginning with RC4.

Shai

Masterrer’s picture

I'm now having the same problem on one of my sites, when I have an imagefield set to display above the body field.

Same here using 5.0 rc4

bcobin’s picture

Same 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">

choster’s picture

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

sylvain_a’s picture

suscribe
Currently not working with RC4 version.

todd nienkerk’s picture

All: 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.

todd nienkerk’s picture

Priority: Critical » Normal

Switching to normal priority because lack of CCK support isn't a show-stopper.

mcjim’s picture

Well, 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.

Shai’s picture

Todd, 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

todd nienkerk’s picture

Title: Read More link not inline at end of node body » Read More link not inserted properly when CCK fields are displayed before node body

All: 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 fields

In 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:

  1. Should the Read More link module keep things simple and just append the link to the end of the teaser regardless of any CCK fields, or should it add itself to the end of the node body and treat CCK field output as separate? (IMO, it should append the link to the node body regardless of what CCK fields appear above and below.)
  2. Where is the best place to insert the link: hook_nodeapi() or template_preprocess_node()? (And if it's the latter, should we use $teaser or $node->content['body']['#value']?)
kay_v’s picture

Hi 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

Shai’s picture

Question #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

todd nienkerk’s picture

To 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 allow span elements.

Back to template_preprocess_node()...

todd nienkerk’s picture

Okay! I think I've fixed it. Check out 6.x-5.0-RC5.

choster’s picture

Status: Active » Reviewed & tested by the community

Awesome, working great for me. Thanks for the quick work.

djs_core’s picture

Version: 6.x-5.0-rc4 » 6.x-5.0-rc5
Status: Reviewed & tested by the community » Active
StatusFileSize
new80.67 KB

For 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/

todd nienkerk’s picture

Status: Active » Fixed

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

mcjim’s picture

Status: Fixed » Active

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

mcjim’s picture

Status: Active » Fixed

Whoops. Changed back to fixed.

djs_core’s picture

Todd 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 ;)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.