1

I'm trying to add a piece of markup with a field in hook_node_view(). It's a little thumb icon for a music site, and I want to overlay this image over another field image (which I'll do with CSS). However, it's not rendering, and I feel pretty confident that I'm going about it the right way. Here is my addition to the node array:

$node->content['like'] = array(
            '#theme' => 'image',
            '#path' => '/sites/default/files/likeimg.png',
            '#alt' => 'like',
            '#prefix' => '<div class="like">',
            '#suffix' => '</div>',
            '#weight' => -1,
            '#attributes' => array(
                'class' => array('like-img')
            )
        );

What am I missing? I am using Display Suite with fields in blocks, and Omega 3.

0

2 Answers 2

1

Do you call the render function of your like content inside the node.tpl.php ?

print render($content['like']);
0
2

hook_node_view() is only called within modules that define node content types (ie. through hook_node_info().

What you want to use is hook_node_view_alter(), and render the content in your template file like Mike Vranckx suggested.

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.