You are here

function querypath_examples_show_multiplerss in QueryPath 6

Same name and namespace in other branches
  1. 7.3 querypath_examples.module \querypath_examples_show_multiplerss()
  2. 7.2 querypath_examples.module \querypath_examples_show_multiplerss()

Display the titles of each item in the RSS feed.

1 string reference to 'querypath_examples_show_multiplerss'
querypath_examples_menu in ./querypath_examples.module
Implements hook_menu();

File

./querypath_examples.module, line 488
The main file for querypath_examples.

Code

function querypath_examples_show_multiplerss() {
  $out = '<h2>' . t('Items in the RSS Feed') . '</h2>';
  $out .= '<p>' . t('Display a linked title to each item in the RSS feed') . '</p>';
  $out .= '<p>' . t('Behind the scenes, this is fetching the RSS feed over HTTP, parsing it, and then creating a list of linked items.') . '</p>';
  $urls = array(
    "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml",
    "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/africa/rss.xml",
    "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/americas/rss.xml",
  );
  $feeds = array();
  $feeds = _querypath_examples_show_multiplerss($urls, 10);
  foreach ($feeds as $date => $item) {
    $out .= '<p>' . l($item['title'], $item['link']) . ' <br />From: ' . $item['url'] . ' <br />' . $item['desc'] . ' <br />Published: ' . date("M d, Y H:m:s", $date) . '</p>';
  }
  $code = '<?php
  $urls = array("http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml",
                "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/africa/rss.xml",
                "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/americas/rss.xml");
  $feeds = array();
  $feeds = _querypath_examples_show_multiplerss($urls, 10);

  foreach($feeds as $date => $item) {
    $out .= \'<p>\' . l($item[\'title\'], $item[\'link\'])
            .\' <br />From: \' . $item[\'url\']
            .\' <br />\' . $item[\'desc\']
            .\' <br />Published: \' . date("M d, Y H:m:s", $date) . \'</p>\';
  }
  ?>';
  $out .= '<h2>' . t('The Code:') . '</h2>';
  $out .= highlight_string($code, TRUE);
  $out .= '<h2>' . t('References:') . '</h2>';
  $out .= l('The QueryPath API', 'http://querypath.org');
  return $out;
}