So yes, there are many instances where I need to load a filtered node object and pass it off somewhere.

$node = $node_load($nid);

That works great for CCK, however, it loads the *value* instead of the *view*. This is a pain because I want the Drupal filters to be applied, not just the raw data for each field.

Is there something I'm missing?

Comments

m3avrck’s picture

Status: Active » Closed (fixed)

Nm, seems this is the best approach:

check_markup($node->field_topics[0]['value'], $node->field_topics[0]['filter']);

Right after you load the node, pass in the value and the filter and it works, wahoo!

jkitching’s picture

I tried the line that you posted, but it doesn't do anything for me. I'm using Drupal 5. Any other solutions?

yched’s picture

you should use content_format('field_name', $node->field_topics[0]) - add the formatter as an optional 3dr param, but the default ('default') should do just what you expect.

loze’s picture

just thought id post for anyone having trouble with the code in #1 for D6
i had to use
check_markup($node->field_topics[0]['value'], $node->field_topics[0]['format']);
not
check_markup($node->field_topics[0]['value'], $node->field_topics[0]['filter']);

sobi3ch’s picture

for whole node node_prepare() is the solution

<?php
$node = node_prepare(node_load($nid));
$output = node_view($node , .....); // if you want to pass through theme template
?>
sobi3ch’s picture

sorry for #5, there is something higher, and it's call node_build_content()