/[drupal]/contributions/modules/nodetypeviews/nodetypeviews.pages.inc
ViewVC logotype

Contents of /contributions/modules/nodetypeviews/nodetypeviews.pages.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Wed May 27 11:07:12 2009 UTC (6 months ago) by yaph
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-BETA3, HEAD
Changes since 1.2: +8 -2 lines
File MIME type: text/x-php
Before node list and feed display check whether node type actually exists, though a manipulated path should return a 404 error. In node list view added call to db_rewrite_sql to allow node access modules to add restrictions.
1 <?php
2 // $Id: nodetypeviews.pages.inc,v 1.2 2009/02/02 21:37:38 yaph Exp $
3
4 /**
5 * @file
6 * Page callback file for the Node Type Views module.
7 */
8
9 /**
10 * Create the teaser list for the given node type
11 *
12 * @param String $type
13 * @return String $output - the HTML markup of the view
14 */
15 function nodetypeviews_type_teaser_view($type) {
16 if (!nodetypeviews_check_type($type)) {
17 return '';
18 }
19 $output = '';
20 $result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = '%s' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $type);
21 while ($node = db_fetch_object($result)) {
22 $output .= node_view(node_load($node->nid), 1);
23 }
24 $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
25 drupal_add_feed(url($type .'/feed'), t('RSS - '. $type));
26 return $output;
27 }
28
29 /**
30 * Create an RSS feed for the given node type
31 *
32 * @param String $type
33 * @return String - the XML feed
34 */
35 function nodetypeviews_type_teaser_feed($type) {
36 if (!nodetypeviews_check_type($type)) {
37 return '';
38 }
39 $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = '%s' AND n.status = 1 ORDER BY n.created DESC"), $type, 0, variable_get('feed_default_items', 10));
40 $channel['title'] = variable_get('site_name', 'Drupal') .' '. $type;
41 $channel['link'] = url($type, array('absolute' => TRUE));
42 $channel['description'] = $term->description;
43
44 $items = array();
45 while ($row = db_fetch_object($result)) {
46 $items[] = $row->nid;
47 }
48
49 node_feed($items, $channel);
50 }

  ViewVC Help
Powered by ViewVC 1.1.2