I've created a custom content in my module and I would like to display the node title as $node->title, $node->myfield.
I've tried

function custom_content_type_view($node, $teaser = FALSE, $page = FALSE) {
  $node = node_prepare($node, $teaser);
  $node->title = $node->title." ".$node->myfield;
  $node->content['body'] = array(
    '#value' => theme('my_view', $node),
    '#weight' => 1,
  );

  return $node;
}

but the title is always the same.
Can someone suggest me a solution?
TIA

Comments

frenkx’s picture

It might not solve your problem since it looks like you want only the view to change (IMHO this is more of a theming problem...), but you could set the node title to the wanted value. To do that, you might want to try to use the hook_nodeapi($node, $op) - at least, that is the hook used in the project Automatic Nodetitles.

Your code could be something like

function custom_content_type_nodeapi($node, $op) {
  if ($op == 'presave' && $node->type == 'custom_content_type') {
    $node->title = $node->title." ".$node->myfield;
  }
}
upupax’s picture

Both your and my solution bring me to the same result: I can see the $node->title with the desired value in Dev Render variables using devel module, but I can't display it!