您当前的位置:首页 > 网络教程 > 帝国CMS教程

帝国cms ajax获取当前栏目最新页面

模板页面

<script type="text/javascript" src="http://img.lanrentuku.com/img/js/jquery.js"></script>
<script src="[!--news.url--]e/extend/ajaxnews.php?classid=[!--classid--]" type="text/javascript"></script>
<!--频道页面将[!--classid--]换成[!--self.classid--]-->
</head>
 
<body>
<div>
<ul id="ajaxnews">
</ul>

e/extend/ajaxnews.php文件

<?
require("../class/connect.php");
require("../class/db_sql.php");
$link=db_connect();
$empire=new mysqlquery();
$html="";
$classid = intval($_GET['classid']);
if($classid){
    $classpath = $empire->fetch1("select classpath from {$dbtbpre}enewsclass where classid=".$classid);
    $classpath = $classpath['classpath'];
    $db_sql = "select * from {$dbtbpre}ecms_news where classid = $classid order by newstime desc limit 10";
    $sql=$empire->query($db_sql);
    while($r=$empire->fetch($sql))
    {
        $html.="<li><a href=".$public_r['newsurl'].$classpath."/".$r['newspath']."/".$r['filename'].".html>".$r['title']."</a></li>";
    }
}
?>
$(function(){
    $("#ajaxnews").html("<?=$html?>");
});
<?
db_close();
$empire=null;
?>

你觉得文章内容怎么样

阿里云代金券 100 云产品通用

有效期30天 首购用户

立即领取
阿里云代金券 100 云产品通用

有效期30天 复购+升级

立即领取