Reputation: 99
Below is the structure of a multidomensional array. How can I get the value of "title" or any of the values within #object?
$content (Array, 2 elements)
links (Array, 5 elements)
body (Array, 16 elements)
#theme (String, 5 characters )
#weight (Integer)
#title (String, 4 characters )
#access (Boolean)
#label_display (String, 6 characters )
#view_mode (String, 6 characters )
#language (String, 2 characters )
#field_name (String, 4 characters )
#field_type (String, 17 characters )
#field_translatable (String, 1 characters )
#entity_type (String, 4 characters )
#bundle (String, 7 characters )
#object (Object) stdClass
vid (String, 2 characters )
uid (String, 1 characters )
title (String, 55 characters ) **THIS IS THE VALUE THAT I NEED**
log (String, 0 characters )
status (String, 1 characters )
The error that I get after implementing AJ's solution is:
Notice: Undefined index: body in include() (line 84 of C:\wamp\www\sdnn_drupal\sites\all\themes\sdnn\node.tpl.php).
Notice: Trying to get property of non-object in include() (line 84 of C:\wamp\www\sdnn_drupal\sites\all\themes\sdnn\node.tpl.php).
line 84 of node.tpl.php is what AJ suggested:
<?php echo $content['body']['#object']->title ?>
Upvotes: 0
Views: 178
Reputation: 28174
$title=$content['body']['#object']->title;
But it also looks like it might be accessible at:
$title=$content['body']['#title'];
Upvotes: 4