function ctools_node_content_render_node

1 call to ctools_node_content_render_node()
ctools_node_content_content_type_render in plugins/content_types/node_context/node_content.inc
Render the node content.

File

plugins/content_types/node_context/node_content.inc, line 65

Code

function ctools_node_content_render_node($node, $conf) {
    if (empty($node->content)) {
        // Copied from node_build_content() so we can fiddle with it as we render.
        $node->content = array();
        // The 'view' hook can be implemented to overwrite the default function
        // to display nodes.
        if (node_hook($node, 'view')) {
            $node = node_invoke($node, 'view', $conf['build_mode']);
        }
        // Build fields content.
        // In case of a multiple view, node_view_multiple() already ran the
        // 'prepare_view' step. An internal flag prevents the operation from running
        // twice.
        field_attach_prepare_view('node', array(
            $node->nid => $node,
        ), $conf['build_mode']);
        entity_prepare_view('node', array(
            $node->nid => $node,
        ));
        $node->content += field_attach_view('node', $node, $conf['build_mode']);
        // Always display a read more link on teasers because we have no way
        // to know when a teaser view is different than a full view.
        $links = array();
        if ($conf['build_mode'] == 'teaser') {
            $links['node-readmore'] = array(
                'title' => t('Read more'),
                'href' => 'node/' . $node->nid,
                'attributes' => array(
                    'rel' => 'tag',
                    'title' => strip_tags($node->title),
                ),
            );
        }
        $node->content['links'] = array(
            '#theme' => 'links__node',
            '#links' => $links,
            '#attributes' => array(
                'class' => array(
                    'links',
                    'inline',
                ),
            ),
        );
        if (empty($conf['no_extras'])) {
            // Allow modules to make their own additions to the node.
            $langcode = $GLOBALS['language_content']->language;
            module_invoke_all('node_view', $node, $conf['build_mode'], $langcode);
            module_invoke_all('entity_view', $node, 'node', $conf['build_mode'], $langcode);
        }
    }
    // Set the proper node part, then unset unused $node part so that a bad
    // theme can not open a security hole.
    $content = $node->content;
    $content += array(
        '#theme' => 'node',
        '#node' => $node,
        '#view_mode' => $conf['build_mode'],
        '#language' => NULL,
    );
    // Add contextual links for this node, except when the node is already being
    // displayed on its own page. Modules may alter this behavior (for example,
    // to restrict contextual links to certain view modes) by implementing
    // hook_node_view_alter().
    if (!empty($node->nid) && !($conf['build_mode'] == 'full' && node_is_page($node))) {
        $content['#contextual_links']['node'] = array(
            'node',
            array(
                $node->nid,
            ),
        );
    }
    // Allow modules to modify the structured node.
    $type = 'node';
    drupal_alter(array(
        'node_view',
        'entity_view',
    ), $content, $type);
    // Kill the links if not requested.
    if (!$conf['links']) {
        $content['links']['#access'] = FALSE;
    }
    return $content;
}