Drupal 6.16
Wysiwyg 6.x-2.1
CKEditor 3.2.0.5205
Read More Link 6.x-5.0-rc7

Comments

matulis’s picture

Looks like wysiwyg module wraps teaser break into a paragraph <p><!--break--></p>,
which causes this side effect.
If delete <p> tag manually and leave only <!--break-->, then read more link will be displayed inline with the teaser.

DrippelDrop@drupal.org’s picture

Funnily I have these same modules like you have... and the same problems too. Any ideas how to solve this without editing the article-source by hand?

matulis’s picture

I gave up on Read more link module and modified node.module

@@ -1041,6 +1041,13 @@ function node_prepare($node, $teaser = FALSE) {
     $node->body = check_markup($node->body, $node->format, FALSE);
   }
   else {
+    /* Patch :: start :: Inline Read more links */
+    if($node->readmore) {
+      $readmore = '&nbsp;'. l(t('read more'), 'node/' . $node->nid, array('attributes' => array('class' => 'readmore')));
+      $p_last_pos = strripos($node->teaser, '</p>');
+      $node->teaser = substr($node->teaser, 0, $p_last_pos) . $readmore . '</p>';
+    }
+    /* Patch :: end */
     $node->teaser = check_markup($node->teaser, $node->format, FALSE);
   }
altrugon’s picture

Here is my solution, it has been created for views but the idea is the same.

My views-view-field--teaser.tpl.php file:

  // print more link only if nid is set
  if (isset($row->nid)) {
    $read_more = ' <span class="views-field-more">' . l('Read more', 'node/'. $row->nid, array('attributes' => array('class' => 'more'))) . '</span>';
    $last_p = strripos($output, '</p>');
    if ($last_p === FALSE) {
      $output .= $read_more;
    }
    else {
      $output = substr($output, 0, $last_p) . $read_more . substr($output, $last_p);  // do not assume teaser ends just with a '</p>'
    }
  }
  
  print $output;
todd nienkerk’s picture

Status: Active » Closed (won't fix)

Unfortunately, it looks like this is a problem with the WYSIWYG module adding the <p> tags as described above. It's very difficult for the Read More module to work around bad markup (like an HTML comment wrapped in a paragraph tag).

jimmb’s picture

I'm having the same issue. However, the rich-text editor here is *not* putting the <!--break--> tag within new <p> </p> tags. Instead, it is coded like this:

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><!--break--><p>additional text...</p>

And yet with this code, the "Read More" link is still pushed below as though in a new paragraph.

I've found a workaround, though, where you add the <!--break--> command within the paragraph tag, as follows:

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<!--break--></p>

That works for me, and hopefully the client won't be too confused by it. But since this deviates from the normal way of placing the <!--break--> command, it'd be better if this workaround wasn't needed.

Jim