5 * Template preprocessor for views-view-views-rss-fields.tpl.php.
7 function template_preprocess_views_view_views_rss_fields(&$vars) {
10 // Set basic info - title, description - about the feed
11 $vars['viewtitle'] = variable_get('site_name', array()) .
' | ' .
$view->display
[$view->current_display
]->display_title
;
13 if ($view->style_options
['description']['feed_description']) {
14 $description = $view->style_options
['description']['feed_description'];
17 $description = variable_get('site_mission', '');
19 $vars['description'] = theme('views_rss_feed_description', $description, $view);
21 // Base URL for link tag
23 $vars['link'] = $base_url;
25 // Grab the rows, push to field mapping function, gather namespaces.
26 $elements = $namespaces = array();
28 $items = $view->style_plugin
->map_rows($vars['rows']);
29 foreach($items as
$item) {
30 // Special handling for GeoRSS.
31 if (isset($item['lat']) && isset($item['lon'])) {
32 $item['georss:point'] = $item['lat'] .
' '.
$item['lon'];
36 $rows .
= theme('views_rss_fields_item', $item);
37 foreach ($item as
$k => $v) {
41 $vars['rows'] = $rows;
42 foreach ($elements as
$e) {
43 if ($namespace = $view->style_plugin
->xml_namespace($e)) {
44 $namespaces[] = "xmlns:{$namespace['local']}=\"{$namespace['namespace']}\"";
47 $vars['namespaces'] = implode(' ', $namespaces);
50 drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
54 * Template preprocessor for views-rss-fields-item.tpl.php.
56 function template_preprocess_views_rss_fields_item(&$vars) {
57 $item = $vars['item'];
60 if (isset($item['lat']) && isset($item['lon'])) {
61 $item['georss:point'] = check_plain($item['lat'] .
' ' .
$item['lon']);
66 // Loop through key=>value pairs
68 foreach ($item as
$key => $value) {
70 $row .
= "<$key>".
check_plain($value) .
"</$key>\n";
78 * Theme function for feed icon.
80 function theme_views_rss_feed_icon($url, $title, $icon) {
81 if ($image = theme('image', $icon, t('Download RSS Feed'), $title)) {
82 return '<a href="'.
check_url($url) .
'" class="feed-icon">'.
$image .
'</a>';
87 * Theme function for feed description.
89 function theme_views_rss_feed_description($description, $view) {