function views_rss_core_preprocess_channel_date in Views RSS 8.2
Same name and namespace in other branches
- 8.3 modules/views_rss_core/views_rss_core.inc \views_rss_core_preprocess_channel_date()
- 6.2 modules/views_rss_core/views_rss_core.inc \views_rss_core_preprocess_channel_date()
- 7.2 modules/views_rss_core/views_rss_core.inc \views_rss_core_preprocess_channel_date()
Preprocess function for channel <lastBuildDate> element.
It will return values for date element providing that original Views query was modified appropriately by views_rss_core_views_query_alter() by adding a field to SELECT clause retrieving object modification timestamp (for <lastBuildDate>).
File
- modules/
views_rss_core/ views_rss_core.inc, line 141 - Preprocess functions for Views RSS: Core Elements module.
Code
function views_rss_core_preprocess_channel_date(&$variables) {
// @TODO make this function friendly for already formatted dates.
if (count($variables['view']->result) > 0) {
$max_date = 0;
foreach ($variables['view']->result as $row) {
$key = $variables['elements'][0]['key'];
if (isset($row->{$key}) && $row->{$key} > $max_date) {
$max_date = $row->{$key};
}
}
if ($max_date) {
$variables['elements'][0]['value'] = date('r', $max_date);
}
}
}