diff --git a/page_manager/plugins/tasks/node_view.inc b/page_manager/plugins/tasks/node_view.inc index b8a7e0c..f2444d7 100644 --- a/page_manager/plugins/tasks/node_view.inc +++ b/page_manager/plugins/tasks/node_view.inc @@ -78,13 +78,6 @@ function page_manager_node_view_menu_alter(&$items, $task) { * node view, which is node_page_view(). */ function page_manager_node_view_page($node) { - // Load my task plugin - $task = page_manager_get_task('node_view'); - - // Load the node into a context. - ctools_include('context'); - ctools_include('context-task-handler'); - // We need to mimic Drupal's behavior of setting the node title here. drupal_set_title($node->title); $uri = entity_uri('node', $node); @@ -94,6 +87,30 @@ function page_manager_node_view_page($node) { drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE); $contexts = ctools_context_handler_get_task_contexts($task, '', array($node)); + // Prep the node to be displayed so all of the regular hooks are triggered. + // For consistency with core, duplicate the code from node_view_multiple() + // rather than node_view() directly. Note that the output is discarded as it + // will be compiled by the appropriate Page Manager task handler afterwards. + $nodes = array($node->nid => $node); + $view_mode = 'full'; + $langcode = NULL; + field_attach_prepare_view('node', $nodes, $view_mode, $langcode); + entity_prepare_view('node', $nodes, $langcode); + foreach ($nodes as $node) { + node_view($node, $view_mode, $langcode); + } + + // Load my task plugin + $task = page_manager_get_task('node_view'); + + // Load the node into a context. + ctools_include('context'); + ctools_include('context-task-handler'); + + // Load all contexts. + $contexts = ctools_context_handler_get_task_contexts($task, '', array($node)); + + // Build the full output using the configured CTools plugin. $output = ctools_context_handler_render($task, '', $contexts, array($node->nid)); if ($output != FALSE) { node_tag_new($node);