Problems to separate teaser/body/fields using CCK

yan - April 14, 2007 - 22:54

I'm trying a bunch of time now to get a seperate teaser field and additional other fields in my nodes, that I can theme as I want. But with every way to solve my problem y encountered another one. I'm using CCK but I couldn't figure out how to make a separate teaser field with it. So I'm using the excerpt module which works fine. But: When ich add more fields to my node, they always show up in the teaser and/or the body when I work on the theming (either with the contemplate module or with the node-.tpl.php files).

The ideal would be having seperate fields for title, author (just a text field, not the publisher), teaser, body (without teaser so that I can assign them different classes), ... and then call them by variables to assign them css classes/id's. But as I said I can't get the teaser separated from the CCK fields. And I don't get why $node->body gives out or the teaser or the teaser AND the body (depending on the view: list or whole node).

I'm sorry if my description is a little difficult to understand, but maybe somebody can help me. I'm looking for this for a long time already.

More or less like this for the list view:

<h2 class="title">[title]</h2>
<div id="byline">by <span class="author">[author]</span>, <span class="date">[date]</span></div>
<div id="teaser">[teaser]</div>

And like this for the node view:

<h2 class="title">[title]</h2>
<div id="byline">by <span class="author">[author]</span>, <span class="date">[date]</span></div>
<div id="teaser">[teaser]</div>
<div id="body">[body]</div>

example

yan - April 15, 2007 - 08:35

To be a little more precise: When I

<?php
print $node->teaser
?>
in my node-.tpl.php it includes the other fields I added with CCK. This doesn't make sense to me since there must be a way to use the new fields when I do theming work...

had a similar issue

talen888 - April 21, 2007 - 14:25

i had a similar issue when printing the body field - not sure if will help you - but the solution was to print out the field using a different syntax:

<?php
print $node->content['body']['#value']
?>


so you might try:

print $node->content['teaser'][#value']

hope that helps!?

nope...

yan - April 21, 2007 - 17:08

No, that doesn't really help. But I'm a bit confused: The teaser is a little different from the first paragraph of the body. Is the information safed twice? I'm using the excerpt module and have a seperate field for the teaser. But the teaser is still repeated in the body field (in db).

Additionally I don't quite get why print $node->content['body']['#value'] (or print $node->body) is not displayed in the node list but on the node page.
And in reverse $node->content['teaser']['#value'] (or print $node->teaser) doesn't appear on the page but in the list.

Am I doing it right?

bfdexp - July 7, 2007 - 13:39

I am having trouble getting a teaser (shortened) version of the body to print in views. In views I have the view set up as a block in list_view and the body's handler as a teaser. However when I view the block, the body is full-view? So i replaced the

<?php
print $body
?>

with
<?php
print $node -> teaser
?>

and
<?php
print $node->content['teaser']['#value']
?>

Both display nothing???? The only thing that displays anything is the $body, which is full even though teaser is the selected handler?

same

bushwakko - July 31, 2007 - 09:10

I got the exact same problem!

Same here

ineffable - October 5, 2007 - 09:05

Same here

Have you tried the Contemplate module?

webslinger23 - October 12, 2007 - 07:47

Contemplate allows you to create the html so that you can output exactly what you want. It's best to work outside of the tiny little windows on a different document. I've found it helpful to copy and paste all of the output on the right side to a different document to grok it all. I also tend to work the html on a different document as well, then paste it back into the window. Hope this helps. http://drupal.org/project/contemplate

Exactly the same problem

doeki - November 8, 2007 - 00:07

Exactly the same problem

worked for me

gabriel.px42 - November 14, 2007 - 00:34

<?php print $teaser = substr($node->content['body']['#value'], 0, 220) ?>

And if your teaser make more

zmove - June 10, 2008 - 12:39

And if your teaser make more than 220 character ?

Setting CCK field visibility for teaser and body

JustJamesAus - September 10, 2008 - 12:08

CCK fields can be set to show in the body, the teaser or both, from the 'display fields' tab of the specific CCK type, like at /admin/content/types/[yourtype]/display

Then you can toggle which fields appear in the teaser or body independantly, as well as how they are labelled. Is that what you're looking for?

 
 

Drupal is a registered trademark of Dries Buytaert.