By raider.adam on
I have the following code in a custom block on my site.
$content_type = 'story';
$myResult = 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 desc"));
while ($node = db_fetch_object($myResult)) {
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
}
print $output;
It is to list the most recent story postings on the site. The thing is, I don't want the teaser to show, just the linked title.
I thought setting the second parameter to false would do it, but it actually displays the full body instead.
Any recommendations on how to display just the linked titles?
Comments
node api or theming
You can solve that with theming (simply write a theme to your node type), or - i think - you could create a simple module, implement hook_nodeapi ( http://api.drupal.org/api/function/node_view/6 ) and set $node->teaser=""; in case when the $op=="view" ...
I hope I helped...
----------------------------------------
Boldizsár Bednárik ing.
http://www.bboldi.com
I am not sure how theming it
I am not sure how theming it will help. The issue, as I understand it, is that I am passing to $block->content the link and the teaser.
I haven't written a module. I will see if I can figure it out and try that.
Heh ... easier than I
Heh ... easier than I thought. I successfully made a module to accomplish it. I put in for a CVS account to upload the module. The code is here:
<?php
// $Id$
/**
* @file
* Display recent content on the site.
*
**/
/**
* Generate HTML for the recent_content block
* @param op the operation from the URL
* @param delta offset
* @returns block HTML
*/
function recent_content_block ($op= 'list', $delta=0){
$content_type = 'story'; // The type of content to display
// For block lists
if ($op == "list") {
$block[0]["info"] = t('Recent Content');
return $block;
} else if ($op= 'view') {
// block content
$result = db_query("SELECT nid, title FROM {node} where type ='" . $content_type . "'");
// content variable
$block_content = '';
while ($links = db_fetch_object($result)) {
$block_content .= l($links->title, 'node/'. $links->nid) .'
';
}
// In case there is no content
if ($block_content == '') {
// No content exists
return;
}
// set up the block
$block['subject'] = 'Recent Content';
$block['content'] = $block_content;
return $block;
}
} // end recent_content_block