Sunday, August 17, 2008

latest 10 news article in runcms

----function defenition---
function b_t()
{
global $db, $myts;

include_once(XOOPS_ROOT_PATH."/modules/news/cfg.php");

$block = array();


// $result = $db->query("SELECT storyid, title FROM ".$db->prefix("stories")." WHERE (published > ".$tdate." AND published < ".time().") ORDER BY counter DESC", 1, 0);
$result = $db->query("SELECT `storyid`, `title` FROM ".$db->prefix("stories")." WHERE `published`!=0 order by `storyid` desc LIMIT 10");
$block['content']="<ol>";
while( $arr=$db->fetch_array($result))
{
$block['content'].="<li><a href='".news_url_story($arr["storyid"])."'>". $arr["title"]."</a></li>";
}
$block['content'].= "</ol>";
$block['title'] = _MB_NEWS_TITLE10;

//$block['content'] = news_url_story($id, $title="", 0);
/* $block['content']="<ol>";
foreach($arr as $ar)
{
$block['content'].="<li>".$ar["storyid"]."</li>";
}
$block['content'].= "</ol>";*/


return $block;
}
--xoops version.php
$modversion['blocks']["some_no"]['file'] = 'file_name.php';
$modversion['blocks']["some_no"]['name'] = _MI_NEWS_BNAME10;
$modversion['blocks']["some_no"]['description'] = 'Shows news topics';
$modversion['blocks']["some_no"]['show_func'] = 'b_t';

No comments:

Post a Comment