The 'read more' link is always displayed, even if all of the content of the node is revealed.

A patch is attached.

Summary: If the length of $node->teaser is equal to or larger than the teaser_size variable, assume that there is more to the article not shown and display the read more link.

I know this isn't perfect because drupal doesn't hard limit the length so if the actual article length is close to the teaser size (within a word), there could be a read more link even though the whole article is shown.

*shrug* this has been an issue for atleast nine months (http://drupal.org/node/26409), figured something that works 99% of the time would be fine, even though it is a quick fix :p

CommentFileSizeAuthor
#11 58202_3.patch2.16 KBsamc
#10 58202_2.patch2.03 KBsamc
#4 58202.patch2.14 KBsamc
read_more2.patch525 bytesbullerk

Comments

bullerk’s picture

Status: Active » Needs review

forgot to set the status to patch ^^;

Marco Palmero’s picture

yes this was a frustrating thing about flexinode, thanks

Bèr Kessels’s picture

Status: Needs review » Needs work

This is not the correct way, sorry. This will introduce fuzzyness. the readmore will often appear when it should not and often not, when it should. Then having it always show up is a better solution.

samc’s picture

Status: Needs work » Needs review
StatusFileSize
new2.14 KB

There are two situations in which the Read More link should be displayed:
1) There are fields where (teaser content != body content)
2) There are fields that are not displayed in the teaser

The attached patch implements this logic.

Unless I'm missing something, this should work 100% of the time ;-)

Bèr Kessels’s picture

Your logic seems strange:

 if (!empty($body_data) && $body_data) {
 }
 else {
   $node->readmore = TRUE;
 }

You are saying: if there is no $body_data AND body_data is empty, set the readmore TRUE....

please explain this, in detail. I fear I missed something. Else set status to "code needs work".

samc’s picture

Thanks for reviewing.

I think the patch got misapplied somehow in what you are looking at. The else in your snippet goes with the if ($field->show_teaser).

This is the resulting code, but massaged a bit for readability:

        if (!empty($body_data) && $body_data) {
          $node->body .= theme('flexinode_'. $field->field_type, $field->field_id, $field->label, $node->$fieldname, $teaser ? $teaser_data : $body_data);

          if ($field->show_teaser) {

            if ($body_data != $teaser_data) $node->readmore = TRUE;

            $node->teaser .= theme('flexinode_'. $field->field_type, $field->field_id, $field->label, $node->$fieldname, $teaser_data);

          }
          else $node->readmore = TRUE;

        }

The outer if just checks for valid content. If there is content, it is appended to the node's body.

Then we look at whether the field is to be displayed in the teaser.

If it is, and the body contains more (i.e. different) stuff than the teaser itself, we want to set READMORE.

If it isn't, then we know we want to set READMORE.

Does this help?

samc’s picture

Note, alignment got messed up in first if above.

This is the actual resulting code that should be produced by the patch:

        if (!empty($body_data) && $body_data) {
          $node->body .= theme('flexinode_'. $field->field_type, $field->field_id, $field->label, $node->$fieldname, $teaser ? $teaser_data : $body_data);
          if ($field->show_teaser) {
            if ($body_data != $teaser_data) {
              $node->readmore = TRUE;
            }
            $node->teaser .= theme('flexinode_'. $field->field_type, $field->field_id, $field->label, $node->$fieldname, $teaser_data);
          }
          else {
            $node->readmore = TRUE;
          }
        }
Bèr Kessels’s picture

Status: Needs review » Needs work

any chance of making this a real patch?

samc’s picture

Is there something wrong with the one that's attached in #4?

http://drupal.org/node/58202#comment-92140

samc’s picture

Status: Needs work » Needs review
StatusFileSize
new2.03 KB

Rerolled patch against CVS.

samc’s picture

StatusFileSize
new2.16 KB

fixed problem w/ generating body

Bèr Kessels’s picture

Status: Needs review » Fixed

Committed. thanks all!

Anonymous’s picture

Status: Fixed » Closed (fixed)