For the life of me I can't figure this out. I can make a custom CCK document, everything is peachy, I can select what is shown in the teaser and what's in the full version of the article posted, but on the main page when I look at the teaser, I don't see the "Read More" link. It's not very intuitive to have to click on the title of the article. Is this configurable somewhere ??? How do I get the "Read More" link. I don't have that problem on my other site...it shows up auomatically...it's an older version though. Appreciate any speedy input here.

Comments

dendrob’s picture

nedjo’s picture

Component: User interface » Code
Category: support » bug
Status: Active » Fixed
StatusFileSize
new687 bytes

The read more link appears when the value for $node->readmore is TRUE, which happens when the node body is longer than the node teaser, indicating that there is more to be read.

This calculation is made in node module before we override the standard teaser in CCK Teaser Field. So whether or not there is a read more link depends on what the relative length of the teaser was originally--even though this comparison is now meaningless.

So, presumably, we should always set the readmore property to TRUE when we override the teaser. I've applied the attached patch to do so.

Please reopen this issue if that doesn't address the problem.

niklp’s picture

I had an inkling that there was something like this going on... but I just ignored it as I didn't have time to worry about it! :p

Glad to see someone's sorted it out, thanks very much. Will post any further findings.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

TBarregren’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new582 bytes

It seems to me that the bug is still there. The read more link appears only after I have entered a sufficient long text in the body. The attached patch moves the $node->readmore = true to the 'view' branch of hook_nodeapi. That works for me.

nedjo’s picture

Assigned: dendrob » Unassigned
Status: Needs review » Reviewed & tested by the community

Thanks. Please go ahead and apply the patch to HEAD and to the DRUPAL-5 branch.

TBarregren’s picture

Assigned: Unassigned » TBarregren
Status: Reviewed & tested by the community » Fixed

I have applied the patch to HEAD and to the DRUPAL-5 branch.

igorik’s picture

Status: Fixed » Active

Hi

I just tried latest CCK teaser module (Janurary 24th) and the read more link is not visible to me on frontpage.
Are there any necessary module for it? When I disable CCK teaser module and enable Excerpt module, I have read more link again.

Thanks
Igor
http://www.somvprahe.sk

bobmarchman’s picture

Status: Needs work » Active

I had the same problem on my site (running Drupal 5.7), and after looking at the code inside node.module that handles teasers, I think this may solve the issue:

In node.module, line 721 we have the function node_prepare(). Here is where the $node->readmore flag gets set depending on a few things. It looked to me that when we are viewing a node, $node->teaser doesn't get set (since it's being overridden, maybe), and as such the readmore link wouldn't appear. I think this is because of the conditional inside the node_prepare() function. Basically, if $node->teaser isn't set AND $node->readmore isn't true, then the link never gets added to the $links array. I could be completely off with that explanation, but that's my take on it.

Adding the following to this module seemingly solved the issue:

change:

/**
 * Implementation of hook_nodeapi().
 */
function cck_teaser_field_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  if ($op == 'alter' && $field = variable_get('teaser_field_'. $node->type, 0)) {
    if (isset($node->content[$field]) && !empty($node->content[$field]['#value'])) {
      $node->teaser = $node->content[$field]['#value'];
    }
  }
  elseif ($op == 'view' && $field = variable_get('teaser_field_'. $node->type, 0)) {
    $node->readmore = true;
  }
}

to:

/**
 * Implementation of hook_nodeapi().
 */
function cck_teaser_field_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  if ($op == 'alter' && $field = variable_get('teaser_field_'. $node->type, 0)) {
    if (isset($node->content[$field]) && !empty($node->content[$field]['#value'])) {
      $node->teaser = $node->content[$field]['#value'];
    }
  }
  elseif ($op == 'view' && $field = variable_get('teaser_field_'. $node->type, 0)) {
    $node->teaser = $node->content[$field]['#value'];   /* this explicitly sets $node->teaser, which means our $node->readmore flag will actually get set */
    $node->readmore = true;
  }
}

Anyone think this is patch worthy???

bobmarchman’s picture

Status: Active » Needs work
StatusFileSize
new533 bytes

Ok, went ahead and rolled up a quick patch anyway...

Felicity’s picture

Hello,

I've tried the changes that you've made, but I still have the same problem :(

The "read more" is invisible when using both "cck teaser field" module & "Read More Tweak" module.

Any more ideas please?

bobmarchman’s picture

Does it work with the Read More Tweak module disabled?

keenubee’s picture

Status: Active » Needs work

Felicity, in your case try to modify "cck_teaser_field.module"

before:

function cck_teaser_field_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  if ($op == 'alter' && $field = variable_get('teaser_field_'. $node->type, 0)) {
    if (isset($node->content[$field]) && !empty($node->content[$field]['#value'])) {
      $node->teaser = $node->content[$field]['#value'];
    }
  }
  elseif ($op == 'view' && $field = variable_get('teaser_field_'. $node->type, 0)) {
    $node->readmore = true;
  }

after:

function cck_teaser_field_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  if ($op == 'alter' && $field = variable_get('teaser_field_'. $node->type, 0)) {
    if (isset($node->content[$field]) && !empty($node->content[$field]['#value'])) {
      $paath = "node/" . $node->nid;
      $read_more = l(t(' More »'),$paath, NULL, NULL, NULL, TRUE, TRUE);
      $teas_content = $node->content[$field]['#value'];
      $teas = substr_replace($teas_content, $read_more, strrpos($teas_content, '</p>'), 0);
      $node->teaser = $teas;
    }
  }

it works fine 4 me =)

popthestack’s picture

Here's the cck_teaser_field_nodeapi() function from latest patch in "Select multiple fields for teaser view" with a working read more link.

function cck_teaser_field_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  if ($op == 'view' && $teaser && variable_get('teaser_field_'. $node->type, 0)) {
    // Unset body and teaser data to allow content.module to start from scratch.
    $node->teaser = '';
    $node->body = '';
    $node->content['body']['#value'] = l(t('Read full article'), 'node/'. $node->nid);
    $node->readmore = FALSE;
  }
  elseif ($op == 'rss item' && $field = variable_get('teaser_field_'. $node->type, 0)) {
    if (isset($node->content[$field]) && !empty($node->content[$field]['#value'])) {
      $node->teaser = $node->content[$field]['#value'];
      $node->readmore = true;
    }
  }
}

Since it's the teaser the body field should be blank anyway so you can just stick the read more link inside of the body field. Not the most elegant solution, but at least it works.

Edited to add: support for RSS feeds.

luisfeng’s picture

cck teaser field 6.x has the same issue.
Could anyone to make a 'readmore' patch?

rzelnik’s picture

subscribe

mrfelton’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new802 bytes

I found that if you set $node->teaser to a blank value, as this module is doing then the read more link will simply never show. Setting $node->teaser to ' ' instead makes the read more link show up.

Patch attached (made against HEAD)

chromix’s picture

Works fantastically well for me! I'd love to see this added soon.