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
Comment #1
stilllife00 commentedThank you, very useful!
Comment #2
pianomansam commentedThis code, while it solves the issue, doesn't seem very efficient.
Comment #3
john franklin commentedFixed with a simpler approach.
Comment #4
john franklin commentedCommitted.