function.ua_get_news.php
来自「支持中、英、繁三种语言; 3、提供9套风格任意转换; 4、内嵌全球免」· PHP 代码 · 共 38 行
PHP
38 行
<?php
//取得新闻
function smarty_function_ua_get_news($params){
global $news;
global $g_db;
$conditions = array();
$limit = null;
//新闻类型:news_type
extract($params);
$conditions[] = "News.status=1";
if (isset($params['class'])) {
$style_class = "class='".$params['class']."'";
}
if (isset($params['type'])) {
$conditions[] = "News.type_id=".$params['type'];
}
if(isset($params['max'])) {
$limit = intval($params['max']);
$limit = " limit ".$limit;
}else{
$limit = " limit 10";
}
$fields = "News.id AS NewsId,News.title as NewsTitle,News.html_file_id as NewsHtmlFileId,News.created as CreateDate";
$tmp_cond = implode(" and ", $conditions);
$sql = "select ".$fields." from ".$news->getTable(true)." where ".$tmp_cond.$limit;
$result = $g_db->GetAll($sql);
$output = "<table id='news".getRadomStr(3)."' ".$style_class." cellspacing=0 width='100%'><tr>\n";
$i = 0;
foreach($result as $key=>$val){
$output.="<td><a href='".URL."news/detail.php?id=".$val['NewsId']."' target='_blank'>".$val['NewsTitle']."</a></td>\n";
if (isset($params['wrap']) && (($i%$params['wrap'])==0)) {
$output.="</tr><tr>";
}
}
$output.="</tr></table>";
return $output;
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?