Download & Extend

How to load a CCK node with filters applied?

Project:Content Construction Kit (CCK)
Version:6.x-1.x-dev
Component:General
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

#1

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!

#2

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

#3

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.

#4

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']);

#5

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
?>

#6

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

nobody click here