i am facing inconsistency behavior when working with the pre process functions:
i have 2 content types:
1. the drupal pre define Page content type.
2. a simple content-type called foo, that uses the pre define title and body fields. and some other cck fields.
i have written a pre process function called: MYTHEMENAME_preprocess_node(&$vars, $hook) i surf 2 times and print_r the $vars array:
- when surfing to the Page content type the $vars['title'] and $vars['body'] fields are there with the correct value. (although when prompting the page to the front page the $vars['content'] holds the body field and not the $vars['body'] field as when surfing directly to the Page content type - but thats a different issue)
- when surfing to the foo content type the $vars['title'] is there, the cck fields are there but the $vars['body'] and $vars['content'] fields are always null, when one of them should have content.
is this some king of a bug ? what am i doing wrong ? can anyone direct me to the drupal code position where i can debug and see why this behavior occurs ?
i am using drupal 6. any help will be appreciated.
Comments
First off, you might want to
First off, you might want to download and install the Devel module. Then you'll be able to use dpm($whatever) to give you a much cleaner view of what's in a variable. print_r() is kinda messy.
Then, put dpm($vars) in your preprocess function and get a complete view of what's available to you.
Anyways, I believe what you want to use is $vars['node']->content['body']['#value'] for the body and $vars['node']->title for the title.
If you're still having issues with the variables, you can set those variables yourself in the preprocess function:
thanks man, your work around
thanks man, your work around solved my problem.