By luyendao on
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.
Comments
I'm trying to find the same
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
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
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
Theme teaser to look different than full node.
Control output of teaser and control output of node:
http://drupal.org/node/53464
Solution/Hack
I think it's a bug that $body displays all the other fields of the content type.
My fix is to do:
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
does anyone know if this is going to be fixed?
Thanks for the Hack
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
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?
Is it safe to use #value like your example?
See: http://drupal.org/node/86104#comment-212905
What about this instead:
bookmarking!
bookmarking!
Thanks
It works to me!
I suggest removing the body field from a cck node
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
This the best (and cleanest) solution as body_filter is not a CCK field.
Fixed
This didn't work for me so I commented out the following lines (lines 211 and 212) in "/modules/blog/blog.module"...
Then simply make your own body field using CCK. Problem solved.
-------------------------------
My Drupal site: Download a Book.
Any better solution yet?
I had exactly this issue today whilst demonstrating CCK to a colleague. I ended up doing
print_r($node)to find the body content and after finding it usingprint $node->content['body']['#value'], just as you guys have.However, I told my colleague we'll do it this way for now but I'll find the right way because there is no way Drupal would not provide a way to easily access body content - it's way too smart for that!
Famous last words I suppose :(
Does anyone know if this is still the case with Drupal 6.x???
Cheers
d6
Yes, this is still working for me in D6.
theming images in the body field?
is it possible? I have a client who will be posting content types where they will be wysiwyg entering content that includes images. I simply want to wrap the images with a sliding doors type of css treatment. any techniques would be of huge help.
CSS only
CSS is your only way to theme images inline. With a bit of javascript, you can do quite a lot.
theming images in the body field?
thanks, i have given up on this after trying to use template.php and str_replace() on the image tags in $element['body']['#value'] just to prepend some divs for each image. i'm overriding theme_markup function but its not working in D6. Maybe this function happens before views and that's why. The divs don't show up even though i get a return value that the str_replace happened x-number of times. Here's the non-working attempt:
Use image fields. Please.
This is really a bad way to look at the situation. If you need image formatting, then create a field and theme it's display in the right place. There are also filters that help you locate the image inline the text by using some code in the text (no links, sorry). You can use that approach and create the image tag correctly in the filter code, instead of trying to manipulate strings at the end of the stack.
PS - your code doesn't work because you ignore the return value from str_replace, but I do not recommend investing that path any much more.
thx and filefield filefield insert
thanks a lot, yea i knew that was a bad way to approach it. i have yet to get this detail figured out, but after looking at the Insert module (formerly Filefield Insert) http://drupal.org/project/insert I'm hoping to get at the images in a more graceful way.
Thanks for your help.
-wil