Skip to content

Instantly share code, notes, and snippets.

@cam8001
Created November 9, 2012 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cam8001/4046187 to your computer and use it in GitHub Desktop.
Save cam8001/4046187 to your computer and use it in GitHub Desktop.
Hook node view implementation
/**
* Implements hook_node_view().
*/
function superpoll_node_view($node, $view_mode, $langcode) {
// Provide a link back to the parent poll on superpoll options.
if ($node->type == 'superpoll_option' && $view_mode == 'full') {
$node->content['linkback_to_poll'] = array(
'#theme' => 'superpoll_option_header',
'#title' => $node->title,
'#description' => field_view_field('node', $node, 'field_description'),
'#back_to_poll_link' => l(t('Back to poll'), 'node/' . $node->poll_nid, array('attributes' => array('class' => array('back-to-poll', 'button')))),
'#node' => $node,
'#weight' => -10,
);
}
if ($node->type == 'superpoll' && $view_mode == 'full') {
// Use the core jQuery UI implementation to display modal confirmations.
// @see superpoll_record_vote_callback()
if (superpoll_show_confirmation($node)) {
_superpoll_load_overlay_js();
$confirmation_body = field_get_items('node', $node, 'field_confirmation_body');
$confirmation_body = field_view_value('node', $node, 'field_confirmation_body', $confirmation_body[0]);
$node->content['confirmation_box'] = array(
'#theme' => 'superpoll_confirmation',
'#html' => render($confirmation_body),
'#node' => $node,
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment