1

I have an existing site where a bunch of the fields are set to Hidden in the Display fields for the content type. I don't want to change that because I'm not 100% sure how that will affect other aspects of displaying the page.

When I do a var_export($node, TRUE) I can see the field values are present in the node, they just aren't being rendered in $content.

Can I use hook_nodeapi() to change the field display to "Default" or "Trimmed", etc?

2 Answers 2

2

$node->content will be a string containing the generated HTML output of the node's fields that will be displayed.

In hook_nodeapi() the $node->content is already generated, but you can append the hidden field's value to it if needed, with something like this:

function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
    switch($op) {
        case 'view':
            if($node->type == "mytype") {
                $node->content .= "<div>".$node->field_myfield[0]['value']."</div>";
            }
        break;
    }
}
0

you can try field_view_field function on your node template for your content type:

 print render(field_view_field('node', $node, 'field_name'));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.