Community Documentation

Display a list of a certain content type, with teasers

Last updated May 4, 2009. Created by punboy@aaron.pu... on June 10, 2005.
Edited by bekasu, pwolanin, puregin. Log in to edit this page.

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);

Comments

I need this for Drupal 7

Hello can someone direct me to a link that will help me do the same task using Drupal 7?
Responses are highly appreciated. Thank you!

Use Views

Taniwha Solutions- Drupal Consulting and Implementation. Site design and construction, module development, customization, etc.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 4.6.x

Archive

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.