From 2e86ac1658ff1e097c755d34e5e0337137ba7c7f Mon Sep 17 00:00:00 2001 From: Fabio Varesano Date: Sun, 23 Apr 2006 03:36:35 +0000 Subject: Patch #57216 by fax8 (Fabio Varesano): Added feed for video. It is available at ?q=video/feed . Also added feed icon at the bottom of ?q=video page. --- video.module | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/video.module b/video.module index 0b397bd..1ff71c0 100644 --- a/video.module +++ b/video.module @@ -135,6 +135,12 @@ function video_menu($may_cache) { 'callback' => 'video_page', 'access' => user_access('access video'), 'type' => MENU_SUGGESTED_ITEM); + $items[] = array( + 'path' => 'video/feed', + 'title' => t('videos feed'), + 'callback' => 'video_feed', + 'access' => user_access('access video'), + 'type' => MENU_CALLBACK); $items[] = array( 'path' => 'node/add/video', 'title' => t('video'), @@ -230,10 +236,34 @@ function video_page() { $output .= node_view(node_load($node->nid), 1); } $output .= theme('pager', NULL, variable_get('default_nodes_main', 10)); + // adds feed icon and link + drupal_add_link(array('rel' => 'alternate', + 'type' => 'application/rss+xml', + 'title' => variable_get('site_name', 'drupal') . ' ' . t('videos'), + 'href' => url('video/feed/'))); + + $output .= '
' . theme('feed_icon', url('video/feed')); } return $output; } +/** + * Generate an RSS feed for videos + * + * @return + * feed + */ +function video_feed() { + $channel = array( + 'title' => variable_get('site_name', 'drupal') . ' ' . t('videos'), + 'description' => t('Latest videos on') . ' ' . variable_get('site_name', 'drupal'), + 'link' => url('video', NULL, NULL, TRUE) + ); + + $result = db_query('SELECT n.nid FROM {node} n WHERE n.type = "video" AND n.status = 1 ORDER BY n.created DESC'); + node_feed($result, $channel); +} + /** * Permissions hook * -- cgit v1.2.3