function node_test_node_view

Same name in other branches
  1. 9 core/modules/node/tests/modules/node_test/node_test.module \node_test_node_view()
  2. 8.9.x core/modules/node/tests/modules/node_test/node_test.module \node_test_node_view()
  3. 10 core/modules/node/tests/modules/node_test/node_test.module \node_test_node_view()
  4. 11.x core/modules/node/tests/modules/node_test/node_test.module \node_test_node_view()

Implements hook_node_view().

File

modules/node/tests/node_test.module, line 30

Code

function node_test_node_view($node, $view_mode) {
    if ($view_mode == 'rss') {
        // Add RSS elements and namespaces when building the RSS feed.
        $node->rss_elements[] = array(
            'key' => 'testElement',
            'value' => t('Value of testElement RSS element for node !nid.', array(
                '!nid' => $node->nid,
            )),
        );
        $node->rss_namespaces['xmlns:drupaltest'] = 'http://example.com/test-namespace';
        // Add content that should be displayed only in the RSS feed.
        $node->content['extra_feed_content'] = array(
            '#markup' => '<p>' . t('Extra data that should appear only in the RSS feed for node !nid.', array(
                '!nid' => $node->nid,
            )) . '</p>',
            '#weight' => 10,
        );
    }
    if ($view_mode != 'rss') {
        // Add content that should NOT be displayed in the RSS feed.
        $node->content['extra_non_feed_content'] = array(
            '#markup' => '<p>' . t('Extra data that should appear everywhere except the RSS feed for node !nid.', array(
                '!nid' => $node->nid,
            )) . '</p>',
        );
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.