function template_preprocess_aggregator_item

Prepares variables for aggregator item templates.

Default template: aggregator-item.html.twig.

Parameters

array $variables: An associative array containing:

  • aggregator_item: An individual feed item for display on the aggregator page.

File

drupal/core/modules/aggregator/aggregator.pages.inc, line 293
User page callbacks for the Aggregator module.

Code

function template_preprocess_aggregator_item(&$variables) {
  $item = $variables['aggregator_item'];
  $variables['feed_url'] = check_url($item->link->value);
  $variables['feed_title'] = check_plain($item->title->value);
  $variables['content'] = aggregator_filter_xss($item->description->value);
  $variables['source_url'] = '';
  $variables['source_title'] = '';
  if (isset($item->ftitle) && isset($item->fid->value)) {
    $variables['source_url'] = url("aggregator/sources/{$item->fid}->value");
    $variables['source_title'] = check_plain($item->ftitle);
  }
  if (date('Ymd', $item->timestamp->value) == date('Ymd')) {
    $variables['source_date'] = t('%ago ago', array(
      '%ago' => format_interval(REQUEST_TIME - $item->timestamp->value),
    ));
  }
  else {
    $variables['source_date'] = format_date($item->timestamp->value, 'medium');
  }
  $variables['categories'] = array();
  foreach ($item->categories as $category) {
    $variables['categories'][$category->cid] = l($category->title, 'aggregator/categories/' . $category->cid);
  }
  $variables['attributes']['class'][] = 'feed-item';
}