| 1 |
<?php
|
| 2 |
// $Id: latest_storys.module,v 1.1 2005/11/20 15:57:30 frjo Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_block().
|
| 6 |
*
|
| 7 |
* Generates a block with the latest storys.
|
| 8 |
* $nlimit sets the number of storys to display
|
| 9 |
* $nodetyp sets the node type to display
|
| 10 |
*/
|
| 11 |
function latest_storys_block($op = 'list', $delta = 0) {
|
| 12 |
if ($op == 'list') {
|
| 13 |
$block[0]['info'] = t('Latest articles');
|
| 14 |
return $block;
|
| 15 |
}
|
| 16 |
else if ($op == 'view') {
|
| 17 |
if (user_access('access content')) {
|
| 18 |
$nlimit = 15;
|
| 19 |
$nodetyp = 'story';
|
| 20 |
$block['subject'] = t('Latest articles');
|
| 21 |
$block['content'] = node_title_list(db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = '%s' AND n.status = 1 ORDER BY n.created DESC"), $nodetyp, 0, $nlimit));
|
| 22 |
}
|
| 23 |
return $block;
|
| 24 |
}
|
| 25 |
}
|