function aggregator_feed_items_load

7.x aggregator_feed_items_load($type, $data = NULL)

Loads and optionally filters feed items.


$type: The type of filter for the items. Possible values are:

  • sum: No filtering.
  • source: Filter the feed items, limiting the result to items from a single source.
  • category: Filter the feed items by category.

$data: Feed or category data used for filtering. The type and value of $data depends on $type:

  • source: $data is an object with $data->fid identifying the feed used to as filter.
  • category: $data is an array with $data['cid'] being the category id to filter on.

The $data parameter is not used when $type is 'sum'.

Return value

An array of the feed items.

3 calls to aggregator_feed_items_load()
aggregator_page_category in drupal/modules/aggregator/
Page callback: Displays all the items aggregated in a particular category.
aggregator_page_last in drupal/modules/aggregator/
Page callback: Displays the most recent items gathered from any feed.
aggregator_page_source in drupal/modules/aggregator/
Page callback: Displays all the items captured from the particular feed.


drupal/modules/aggregator/, line 114
User page callbacks for the Aggregator module.


function aggregator_feed_items_load($type, $data = NULL) {
  $items = array();
  switch ($type) {
    case 'sum':
      $query = db_select('aggregator_item', 'i');
      $query->join('aggregator_feed', 'f', 'i.fid = f.fid');
      $query->addField('f', 'title', 'ftitle');
      $query->addField('f', 'link', 'flink');
    case 'source':
      $query = db_select('aggregator_item', 'i');
      $query->fields('i')->condition('i.fid', $data->fid);
    case 'category':
      $query = db_select('aggregator_category_item', 'c');
      $query->leftJoin('aggregator_item', 'i', 'c.iid = i.iid');
      $query->leftJoin('aggregator_feed', 'f', 'i.fid = f.fid');
      $query->fields('i')->condition('cid', $data['cid']);
      $query->addField('f', 'title', 'ftitle');
      $query->addField('f', 'link', 'flink');

  $result = $query->extend('PagerDefault')->limit(20)->orderBy('i.timestamp', 'DESC')->orderBy('i.iid', 'DESC')->execute();

  foreach ($result as $item) {
    $item->categories = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = :iid ORDER BY c.title', array(':iid' => $item->iid))->fetchAll();
    $items[] = $item;

  return $items;