CCk newb question, what's the variable to output the body ? (body_filter)

luyendao - January 19, 2007 - 03:46

I don't know why i can't seem to find this, even after doing print_r($node) - i can't seem to trace the variable i need to output the default node body.

When i do print $body or $node->body it outputs all the custom fields in addition to the body field. My brain has stopped working.

I'm trying to find the same

pshadow - January 20, 2007 - 16:34

I'm trying to find the same thing. Was hoping by moving CCK field from text to using the default body field in Drupal 5 I'd be able to use body and teasers, but print $teaser doesn't work nor does $print body_filter, and $content and $body print all the cck fields. Anyone able to print just the Body and Teaser out of the DB?

Can anyone confirm if this

pshadow - January 22, 2007 - 18:12

Can anyone confirm if this is even possible? Or if going the old route of text.module for CCK body is still the most flexible solution? thanks.

This isn't so much a

luyendao - January 23, 2007 - 18:44

This isn't so much a solution, as a work around - and it doesn't give me the exact control i wanted (in a sense).

I ended up re-creating my CCK node, and removing the label for "Body" - and created my own custom body field. I then used the 'contemplate' module to output all the fields i wanted for teaser and body, that gets spit out in $content in node.tlp.php - then i modified node.tlp.php with a few if statements to make sure other node types weren't affected.

I'm not sure if it's the most elegant way, but it works - the longest part was just going through the 'contemplate' variables, and outputting each one 1 by 1, to get clean output and write clean xhtml.

Hope it helps.

Maybe this will help

wolfderby - April 30, 2007 - 16:25

Theme teaser to look different than full node.

Control output of teaser and control output of node:

http://drupal.org/node/53464

Solution/Hack

John Hwang - February 14, 2007 - 13:36

I think it's a bug that $body displays all the other fields of the content type.

My fix is to do:

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

This is dumb though, because when you install the Devel module and look at the "Devel load" or "Devel render" the they show the body variable only contains the content of the "body" field...

update

kickn - February 20, 2007 - 10:17

does anyone know if this is going to be fixed?

Thanks for the Hack

MacRonin - April 16, 2007 - 09:46

Thanks for the Hack/work around. This was starting to drive me crazy.

I figured I was just doing something stupid since its just 5:30 AM and I needed sleep. Disappointed to see its still not fixed (Drupal 5.1 and CCK 1.4), but glad its not just me. The field list still shows the Body field to be $body_filter but that didn't work, and $content & $body give you the CCK fields also.

-------------------
http://www.PrivacyDigest.com/ News from the Privacy Front
http://www.SunflowerChildren.org/ Helping children around the world

The same problem - field

Kiev1.org - April 18, 2007 - 10:20

The same problem - field body_filter! And it to remove it is impossible and to deduce it in a template in any way it is impossible!

Is this safe to use?

markhope - April 18, 2007 - 11:45

Is it safe to use #value like your example?
See: http://drupal.org/node/86104#comment-212905

What about this instead:

print check_markup($node->content['body']['#value']); //for rich text content

print check_plain($node->content['body']['#value']); //for plain text

bookmarking!

yeeloon - November 30, 2007 - 16:56

bookmarking!

Thanks

lucassouza1 - July 3, 2008 - 20:07

It works to me!

I suggest removing the body field from a cck node

yhager - April 23, 2007 - 10:00

Took me a while to find out how to do this though. If you remove the label for the body field in your content type, the body field will not be presented in node edit or view (which means you can use your own body field).

Go to admin/content/types/ and remove the text under "Body field label:".

Agree

zeropaper - August 2, 2007 - 11:28

This the best (and cleanest) solution as body_filter is not a CCK field.

 
 

Drupal is a registered trademark of Dries Buytaert.