I made a seperate teaser text field for my CCK, and I want it to print teaser if there is a teaser, but if the story is short and no need for a teaser, it will print whole body of story. What code should I use? I figure it would use if ... else ... , but I'm not a coder so I need your help. Thanks in advance.

Comments

mhd’s picture

this is what I have so far, but it print out the whole body, without the teaser

foreach ((array)$field_teaser as $item) {
if(!empty($item['view'])){
print $node->content['body']['#value'];
}
else {
print $item['view'];
}
}
JonSTeps’s picture

Status: Active » Fixed

I ran into the same issue and i put this together, I stink at php, so it's probably not the best code but it works for me.

if($field_teaser[0]['value']):
print check_plain($node->field_teaser[0]['value'])
else:
print $node->teaser
endif;

Anonymous’s picture

Status: Fixed » Closed (fixed)