I've setup a custom CCK type for Header Image module, which only display one image on teaser.
The current code has "readmore" link even if $node->body is empty.

The following line fix it.
Change:

      if ($teaser && $node->readmore) {

to

      if ($teaser && $node->readmore && !empty($node->body)) {

PS: I wonder if there's any implication if it is done this way..

Comments

todd nienkerk’s picture

Version: 6.x-2.0-beta1 » 6.x-3.x-dev
Assigned: Unassigned » todd nienkerk

The same fix may apply to 6.x-3.x-dev. Will investigate.

todd nienkerk’s picture

I used a different method to ensure $node->body isn't empty. Because it's also worthwhile to ensure the teaser contains fewer characters than the body -- if they're equal, the teaser is actually displaying the full node -- I've added some logic that will handle both concerns at once:

    else if ($op == 'view') {
      // Check to make sure that:
      // (1) This is a teaser
      // (2) There's more to read
      // (3) The teaser contains fewer characters than the node body (this also ensures the node body isn't empty)
      if ($teaser && $node->readmore && (strlen($node->teaser) < strlen($node->body))) {
        $node->content['body']['#value'] = ed_readmore_link_place($node->content['body']['#value'], ed_readmore_link_render($node), $display);
      }
    }

The important piece is:

strlen($node->teaser) < strlen($node->body)

If the body is empty, its length equals 0; the teaser cannot possibly have fewer than 0 chars. That statement will return FALSE if $node->body is empty.

I have committed this to the 6.x-3.x-dev branch.

todd nienkerk’s picture

Title: Readmore displayed even if node->body is empty » Read More link displayed even if node->body is empty
Status: Active » Fixed
todd nienkerk’s picture

Status: Fixed » Needs work

Turns out the method I used to check for this is flawed due to some problems with hook_nodeapi's operations ($op) path. I am changing this issue to "needs work."

FYI: I am switching from the hook_nodeapi() to template_preprocess_node() method of appending the link to the end of the node teaser.

todd nienkerk’s picture

Status: Needs work » Fixed

Tested recent changes. I didn't get any "read more" links for blank nodes.

Status: Fixed » Closed (fixed)

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