| 1 |
<?php
|
| 2 |
// $Id: latest_storys.module,v 1.1 2005/11/20 15:57:30 frjo Exp $
|
| 3 |
|
| 4 |
function latest_storys_help($section) {
|
| 5 |
switch ($section) {
|
| 6 |
case 'admin/modules#description':
|
| 7 |
return t('Block that display the latest storys.');
|
| 8 |
break;
|
| 9 |
}
|
| 10 |
}
|
| 11 |
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Implementation of hook_block().
|
| 15 |
*
|
| 16 |
* Generates a block with the latest storys.
|
| 17 |
* $nlimit sets the number of storys to display
|
| 18 |
* $nodetyp sets the node type to display
|
| 19 |
*/
|
| 20 |
function latest_storys_block($op = 'list', $delta = 0) {
|
| 21 |
if ($op == 'list') {
|
| 22 |
$block[0]['info'] = t('Latest articles');
|
| 23 |
return $block;
|
| 24 |
}
|
| 25 |
else if ($op == 'view') {
|
| 26 |
if (user_access('access content')) {
|
| 27 |
$nlimit = 10;
|
| 28 |
$nodetyp = 'story';
|
| 29 |
$block['subject'] = t('Latest articles');
|
| 30 |
$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));
|
| 31 |
}
|
| 32 |
return $block;
|
| 33 |
}
|
| 34 |
}
|