When the teaser has no HTML, then the check to insert it inline fails forcing it to be inserted after. Below is an example of a fix for it by adding an additional check.

read_more_node_view():

<?php
      // Get last position of the last closing marker in teaser.
      if (isset($node->content['body'][0]['#markup']) && preg_match('!</?' . $elements . '[^>]*>\s*$!i', $node->content['body'][0]['#markup'], $match, PREG_OFFSET_CAPTURE)) {
        // Recalculate the position in $teaser. We do this because there may be extra CCK fields appended to the teaser.
        $insert_point = strpos($view_mode, $node->content['body'][0]['#markup']) + $match[0][1];
        // Insert the link.
        $node->content['body'][0]['#markup'] = substr_replace($node->content['body'][0]['#markup'], drupal_render($read_more_link), $insert_point, 0);
      // In case there is no HTML markup
      } elseif(isset($node->content['body'][0]['#markup']) && strip_tags($node->content['body'][0]['#markup']) == $node->content['body'][0]['#markup']) {
        $node->content['body'][0]['#markup'] = rtrim($node->content['body'][0]['#markup']) . drupal_render($read_more_link);
      } else {
        $display = 'after';
      }
?>

Comments

stilllife00’s picture

Thank you, very useful!

pianomansam’s picture

This code, while it solves the issue, doesn't seem very efficient.

john franklin’s picture

Issue summary: View changes

Fixed with a simpler approach.

john franklin’s picture

Status: Active » Fixed

Committed.

  • John Franklin committed 8d609b6 on 7.x-1.x
    Issue #1307400 by John Franklin: If teaser has no HTML, cannot be...

Status: Fixed » Closed (fixed)

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