Read more was working fine until I installed the trackback module. The trackback module appends the following string to the teaser:

<!--
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description rdf:about="http://cyber4kids/node/432" dc:identifier="http://cyber4kids/node/432" dc:title="Der Ferienpass ist da!" trackback:ping="http://cyber4kids/trackback/432" />
</rdf:RDF>
-->

As you can see the teaser is now ending by a comment. Therefore the function ed_readmore_link_place won't recognize the end of the teaser text. To fix this we need to check the teaser without the appended html comment. So I inserted the following condition in the ed_readmore_link_place function, this calls the ed_readmore_link_place function recursively without the last html comment:

    else if (preg_match('%\s*<\!--.*?--\>\s*$%is', $teaser, $match, PREG_OFFSET_CAPTURE)) {
      $teaser = ed_readmore_link_place(substr($teaser, 0, $match[0][1]), $node, $display) . $match[0][0];
    }

I also have attached a patch which contains this solution. I'm not sure about the efficiency/performance of the none-greedy regular expression I used ... please review the expression.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

daemon’s picture

Title: Make read more working with trackback module » Make read more working with comments in teaser
Status: Needs review » Needs work

@ositoblanco: Great work, however, the Adsense module adds comments tags before and after the teaser, causing the patch to create the "read more" link inline but in front of everything.
<!-- google_ad_section_start -->Teaser Text<!-- google_ad_section_end -->

osopolar’s picture

I see ... the regex matches the whole string between the first <!-- and the last --> so we need to refine the regular expression. But at the moment I don't know how. Therefore I asked for help in another forum: http://regexadvice.com/forums/ShowThread.aspx?PostID=54476

I also were thinking about whether this module should use querypath (http://querypath.org / http://drupal.org/project/querypath) or some other domDocument-functions to find the last paragraph and append the read more link. But this solution seems to be more resource intensive. But maybe it could use this as a fallback method?

osopolar’s picture

Try this regex:

\s*<!--(?:(?!<!--|-->).)*?-->\s*$

Thanks to ddrudik from http://regexadvice.com/forums/thread/54480.aspx for this regex.

osopolar’s picture

Status: Needs work » Needs review
FileSize
985 bytes

I changed the patch to the new regex. Please test it!

Todd Nienkerk’s picture

ositoblanco: Thanks for all the work. With which modules have you tested this patch?

daemon: Would it be possible for you to test this patch against the Adsense module you describe above?

osopolar’s picture

I use the patched module just on one website. I have more modules enabled, but I think these seems to be the more relevant once. The read more link works fine, I haven't noticed any problems there.

abuse
better_formats
ed_readmore
email
extlink
fckeditor
filefield
image_resize_filter
insert_view
mollom
nodewords
page_title
service_links
simplenews
spamspan
trackback
views

Todd Nienkerk’s picture

Would someone mind reviewing this solution with the most recent commit of 6.x-5.x-dev? Several changes have been made to the logic that adds the link.

Todd Nienkerk’s picture

Status: Needs review » Postponed (maintainer needs more info)