I don't use the built-in body field for my nodes, but instead use a CCK textarea (you can do so much more with it). Can you add support to show "read more" links with CCK fields? One way I could imagine it working is a global setting which shows all available CCK textarea fields, and you could select that field. Or, you could also choose a CCK field per content type.

What do you think?

Comments

geerlingguy’s picture

Subscribe. And +1 (for archstl.org - right now we're using a custom formatter to do this).

mrfelton’s picture

+1. We use a custom CCK field for the teaser.

geerlingguy’s picture

Just FYI, for now, on archstl.org, we're using a custom CCK formatter to accomplish the read more link. Here's the code (using the custom formatters module):

if ($allowed = _text_allowed_values($element)) {
  $output = $allowed;
} else {
  $output = $element['#item']['safe'];
}

if ($pos = strpos($output, '<!--break-->')) {
  $options = array('html' => true, 'attributes' => array('rel' => 'nofollow'));
  $link = l('Continue reading &raquo;', 'node/' . $element['#node']->nid, $options);
  $output = substr($output, 0, $pos) . '<div class="continue-reading">' . ' ' . $link . '</div>';
}

return $output;
danny_joris’s picture

+1 I don't use the core body field either

danny_joris’s picture

@geerlingguy

I tried your snippet, but I changed it into this:

<?php
  $options = array('html' => true, 'attributes' => array('rel' => 'nofollow'));
  $link = l('read more', 'node/' . $element['#node']->nid, $options);
  $output = substr($element['#item']['safe'], 0, -5) . '&nbsp;<span class="readmore">(' . $link . ')</span></p>';
return $output;

?>

I don't think I use break lines. I just have a separate field for teasers. I removed the last </p> by cutting of the last 5 letters, put the link in it and closed it of manually again. It works, but I feel that it is rather tweaky. Is there a better way to fix this?

Cheers,
Danny

todd nienkerk’s picture

Title: Support CCK body fields » Add Read More link to CCK text fields
Assigned: Unassigned » todd nienkerk

When dealing with CCK fields, a custom formatter is the best solution because there are too many site-specific use cases to supply general CCK support. Both custom formatters and theme-layer solutions (like appending a link in a template file or in a template_preprocess function) would handles these use cases.

Regarding the custom formatter, we have two options: (1) document the custom formatter or (2) supply a custom formatter in the Read More module. I'll have to play around with the code to see if option (2) is viable.

brisath’s picture

Option 2 would be fantastic in #6