function node_feed

cis7 node.module node_feed($nids = FALSE, $channel = array())
cle7 node.module node_feed($nids = FALSE, $channel = array())
elmsmedia7 node.module node_feed($nids = FALSE, $channel = array())
icor7 node.module node_feed($nids = FALSE, $channel = array())
meedjum_blog7 node.module node_feed($nids = FALSE, $channel = array())
mooc7 node.module node_feed($nids = FALSE, $channel = array())

Generates and prints an RSS feed.

Generates an RSS feed from an array of node IDs, and prints it with an HTTP header, with Content Type set to RSS/XML.


$nids: An array of node IDs (nid). Defaults to FALSE so empty feeds can be generated with passing an empty array, if no items are to be added to the feed.

$channel: An associative array containing title, link, description and other keys, to be parsed by format_rss_channel() and format_xml_elements(). A list of channel elements can be found at the RSS 2.0 Specification. The link should be an absolute URL.

3 calls to node_feed()
blog_feed_last in modules/blog/
Menu callback; displays an RSS feed containing recent blog entries of all users.
blog_feed_user in modules/blog/
Menu callback; displays an RSS feed containing recent blog entries of a given user.
taxonomy_term_feed in modules/taxonomy/
Generate the content feed for a taxonomy term.
6 string references to 'node_feed'
drupal-6.bare.database.php in modules/simpletest/tests/upgrade/drupal-6.bare.database.php
Bare installation of Drupal 6.17, for test purposes.
drupal-6.filled.database.php in modules/simpletest/tests/upgrade/drupal-6.filled.database.php
Filled installation of Drupal 6.17, for test purposes.
drupal-6.og-ui.database.php in sites/all/modules/ulmus/og/og_ui/tests/drupal-6.og-ui.database.php
Filled installation of Drupal 6.17, for test purposes.
drupal-6.og.database.php in sites/all/modules/ulmus/og/tests/drupal-6.og.database.php
Filled installation of Drupal 6.17, for test purposes.
node_menu in modules/node/node.module
Implements hook_menu().

... See full list


modules/node/node.module, line 2581
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.


function node_feed($nids = FALSE, $channel = array()) {
  global $base_url, $language_content;

  if ($nids === FALSE) {
    $nids = db_select('node', 'n')->fields('n', array('nid', 'created'))->condition('n.promote', 1)->condition('n.status', 1)->orderBy('n.created', 'DESC')->range(0, variable_get('feed_default_items', 10))->addTag('node_access')->execute()->fetchCol();

  $item_length = variable_get('feed_item_length', 'fulltext');
  $namespaces = array('xmlns:dc' => '');

  // Load all nodes to be rendered.
  $nodes = node_load_multiple($nids);
  $items = '';
  foreach ($nodes as $node) {
    $item_text = '';

    $node->link = url("node/$node->nid", array('absolute' => TRUE));
    $node->rss_namespaces = array();
    $node->rss_elements = array(
        'key' => 'pubDate',
        'value' => gmdate('r', $node->created),
        'key' => 'dc:creator',
        'value' => $node->name,
        'key' => 'guid',
        'value' => $node->nid . ' at ' . $base_url,
        'attributes' => array('isPermaLink' => 'false'),

    // The node gets built and modules add to or modify $node->rss_elements
    // and $node->rss_namespaces.
    $build = node_view($node, 'rss');

    if (!empty($node->rss_namespaces)) {
      $namespaces = array_merge($namespaces, $node->rss_namespaces);

    if ($item_length != 'title') {
      // We render node contents and force links to be last.
      $build['links']['#weight'] = 1000;
      $item_text .= drupal_render($build);

    $items .= format_rss_item($node->title, $node->link, $item_text, $node->rss_elements);

  $channel_defaults = array(
    'version' => '2.0',
    'title' => variable_get('site_name', 'Drupal'),
    'link' => $base_url,
    'description' => variable_get('feed_description', ''),
    'language' => $language_content->language,
  $channel_extras = array_diff_key($channel, $channel_defaults);
  $channel = array_merge($channel_defaults, $channel);

  $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
  $output .= "<rss version=\"" . $channel["version"] . "\" xml:base=\"" . $base_url . "\" " . drupal_attributes($namespaces) . ">\n";
  $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language'], $channel_extras);
  $output .= "</rss>\n";

  drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
  print $output;



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.