简体   繁体   中英

Understanding <?php print $node->content['body']['#value']; ?> in Drupal

sorry, this is a really noob question...

When I want to print part of the $content array within node.tpl.php (for example), I'll use something like <?php print $node->content['body']['#value']; ?> <?php print $node->content['body']['#value']; ?>

I just want to understand what the -> is all about. Presumably this indicates that $node is something other than a normal array? ( Otherwise it'd be $node['content']['body']['#value'] )

Cheers.

$node is an object and content is one of its properties, containing an array.

If the contents of 'content' was also an object, it would be

$node->content->body etc.

I know this is an old thread but the devel module is awesome. You could install devel and use

<?php dpm($node); ?> 

and you will see a lot of information that will help you with your theme-ing. Good luck.

You should consider installing Theme Developer module. With it you can click on elements of your page, and you will get a debug list of all the Drupal or Views related variables which can be accessed by your code.

So you can explore $content, and all it's fields...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM