开发者

Drupal - displaying the title of the node within a block

开发者 https://www.devze.com 2022-12-23 21:59 出处:网络
I\'m needing to dynamically display the title of a node within a block. I would have thought this would be simple, but all the code snippets I\'ve tried don\'t seem to work (e.g. <?php print $node-

I'm needing to dynamically display the title of a node within a block. I would have thought this would be simple, but all the code snippets I've tried don't seem to work (e.g. <?php print $node->title; ?> )

I've checked and tested that the PHP input format is 开发者_Go百科on and working with other PHP bits and bobs, and everything seems OK.

Any ideas?


Use drupal_get_title() for getting the title of the current page.


I thik this link might be of help:

http://www.g-loaded.eu/2009/05/07/drupal-tip-list-a-nodes-taxonomy-terms-inside-a-block/

Based on it:

if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
    $node = node_load(arg(1));
    echo $node->title
}


There is also the option to use the Views module for this.

0

精彩评论

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

关注公众号