Display a list of a certain content type, with teasers

Last modified: May 4, 2009 - 03:02

PLEASE NOTE! The following snippet is user submitted. Use at your own risk!

<?php
/**
* This php snippet displays content of a specified type, with teasers
*
* To change the type of content listed, change the $content_type.
*
* Works with drupal 4.6
*/
 
$content_type = 'story';
 
$result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = '$content_type' AND n.status = 1 ORDER BY n.created ASC"));
  while (
$node = db_fetch_object($result1)) {
   
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
  }
print
$output;
?>

Paged Results

You can page the results by adding this line right before printing the $output:

$output .= theme('pager', NULL, $listlength);

 
 

Drupal is a registered trademark of Dries Buytaert.