In Drupal 7 i want to add node to a another node when the user is loged.
I am using Drupal 7, and I want to add a node inside another node when the user is logged in :
function my_modul_node_view($node, $view_mode, $langcode) {
global $user;
switch ($node->vid) {
case 4:
$node2 = node_load(37);
if ($user->uid > 0) {
$node->content['my_data_field'] = array(
'#markup' => drupal_render($node2),
'#weight' => 10,
);
}
}
}
I am getting the following error message :
Fatal error: Cannot use object of type stdClass as array
I am using the following form :
$form = drupal_get_form('user_login', $node);
$node->content['data_collection_form'] = array(
'#markup' => drupal_render($form),
'#weight' => 10,
);
What is the proper way to do this in my module?
You just need to make one small change as far as I can tell: