开发者

How to modify node output on node view in Drupal programmatically?

I am familiar with Contemplate module, and also the开发者_开发知识库 option of having node.tpl files.

But, how could I alter node content via node api programmatically? I would like to add some custom HTML. Any tips?


i think you are looking for hook_nodeapi functionality which provides possibility to add additional content along with node content.

ex; adds a variable to node which is also available to display in node template

function test_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
    switch ($op) {
    case 'view':
        $node->content['var1'] ='<div>test value</div>';
        break;
    }
}


If you don't want to make a custom module (to implement hook_nodeapi), you may also consider overriding template_preprocess_node in your theme's template.php file. Just rename this function to yourthemename_preprocess_node and code away.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜