I've been using the CCK module to build a custom node in 4.7. And I'm using the contemplate module to build a custom design for the content.

The problem is that the custom node is not being truncated for teasers. There are places for two templates, one for the teaser and one for the node, so there must be a difference in the two types.

I assumed when I started that Drupal would just truncate the node material automatically, but it must not.

How does one trigger truncation on custom nodes????

Comments

karens’s picture

In CCK, instead of one big blob of text you have lots of individual fields, so the usual method of creating a teaser, truncating that one big blob of text, isn't applicable. You're using contemplate, so fixing your teasers is easy. Your contemplate template will default to including all your fields in your teaser. Just go into your template and erase any fields you don't want to see in the teaser from the teaser template and you should be ready to go.

zoon_unit’s picture

Unfortunately, my custom node has several small fields and one BIG field that holds a large amount of text. It is that BIG field that needs to be truncated.

Any ideas???

Also, since Drupal 5 uses a basic CCK structure for all nodes, will it tackle this problem better?

zoon_unit’s picture

I assume that Drupal has a truncation function in core that does the actual job within normal nodes.

Would it be possible to call that function against my text field from within my custom template?

Unfortunately, I know nothing about Drupal core, so I would have no idea how to start.

Any suggestions?

karens’s picture

Try node_teaser($body), substituting $body with your field name. You may have to play with it a bit and this is not tested, but that is what Drupal core uses to create teasers on the body field.

mrwendell’s picture

I have used the node_teaser() function and it works well to give a teaser view of a field. You may also want ot consider copying the code from drupal API handbook and making your own function in the template. That way you can set different teaser sizes, as it stands the node_teaser() uses the teaser size length designated in the admin settings.

ednique’s picture

I have several small fields and one textarea in my custom content type.
For the teasers I only want the content of the textarea as would happen with normal content like page
Also I want to use the "break" tag to seperate the teaser part in the textarea from the rest of the content in the textarea.

Maybe this is what you want too...
This is how I did it:

* Use Contemplate
* As teaser template I choose ("field_verslag" is the name of the textarea field):

<?php 
$teasertext = check_markup($field_verslag[0]['value'], $field_verslag[0]['format'],false);
print node_teaser($teasertext,$field_verslag[0]['format']);
?>

* As body template I keep what is proposed