国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > 帝國Empire > 正文

帝國cms加載更多的使用說明教程

2024-08-28 12:24:42
字體:
來源:轉載
供稿:網友

 在制作移動端頁面時會用到,把以下代碼添加到服務器,按步驟操作即可實現點擊加載更多。

1、將以下代碼上傳至服務器(e/action/)下,命名為getmore.php

<?php

    require('../class/connect.php');

    require('../class/db_sql.php');

    require('../data/dbcache/class.php');

    if($_POST[action] == 'getmorenews'){

    $table=htmlspecialchars($_POST[table]);

    if(empty($_POST[orderby])){$orderby='newstime';}else{ $orderby=htmlspecialchars($_POST[orderby]);}

    if(empty($_POST[myorder])){$myorder='desc';}else{ $myorder='asc';}

    if(empty($_POST[limit])){$limit=6;}else{ $limit=(int)$_POST[limit];}

    if(empty($_POST[classid])){$where=null;}else{ $where='where classid in('.$_POST[classid].')';}

    if(empty($_POST[length])){$length=50;}else{ $length=(int)$_POST[length];}

    if(empty($_POST[small_length])){$small_length=500;}else{ $small_length=(int)$_POST[small_length];}

    // next:第幾頁

    // table:調用數據表

    // limit:每次調用數量

    // small_length:簡介截取字符數

    // length:標題截取字符數

    // classid:調用欄目,允許多個,如1,2,3,4  特別注意,必須是調用同一數據表的欄目

    // orderby:排序,默認是newstime,傳什么就按什么來排序,如 id

    // myorder:正反序,默認是asc,傳值怎為desc

    $link=db_connect();

    $empire=new mysqlquery();

    $num =(int)$_POST['next'] *$limit;

      if($table){

            $sql=$empire->query("SELECT * FROM `".$dbtbpre."ecms_".$table."` $where order by $orderby $myorder limit $num,$limit");

     

        while($r=$empire->fetch($sql)){

     

            if($r[mtitlepic]==''){

                $r[mtitlepic]=$public_r[news.url]."e/data/images/notimg.gif";

            }

        $oldtitle=stripSlashes($r[title]);

        $title=sub($oldtitle,'',$length);

        $smalltext=stripSlashes($r[smalltext]);

        $smalltext=sub($smalltext,'',$small_length);

        $classname=$class_r[$r[classid]][classname];

        $newsurl=$public_r[newsurl];

        $classurl=$newsurl.$class_r[$r[classid]][classpath];

        $urls = sys_ReturnBqTitleLink($r);

    ?>

    <!-- 以下代碼是顯示列表的標簽模板 -->

    <li class='news-list'>

        <a href='<?=$urls?>' title='<?=$r[title]?>' class='date-link'>

            <img src='<?=$r[mtitlepic]?>' alt='<?=$r[title]?>'  class='date-img-url'/>

            <h4 class='date-title'><?=$r[title]?></h4><span class='act-datetime'><?=date("Y-m-d",$r[newstime])?></span>

        </a>

    </li>

    <?php

        }

       }

    }

    db_close();

    $empire=null;

?>


2、在帝國CMS模板后臺,在對應的列表頁面添加以下代碼

 

頁面模板內容(*)

<ul class="list-content  clear" id="showajaxnews">[!--empirenews.listtemp--]<!--list.var1-->[!--empirenews.listtemp--]</ul>   

<div class="more" id="loadmore">點擊加載更多內容</div>

<!-- 需要引入JQ文件 -->

<script src="/skin/fz/js/jquery-1.8.2.min.js" type="text/javascript"></script>

<script>

$(function(){   

     var i = 1; //設置當前頁數

    $('#loadmore').click(function(){

        $.ajax({

            url : 'http://localhost/cms/e/action/getmore.php', // 這是當前服務器的地址

            type:'POST',

            data:{"next":i,'table':'news','classid':'[!--self.classid--]','action':'getmorenews','limit':10,'small_length':120},

            dataType : 'html',

            beforeSend:function(){

                $("#loadmore").show().html('<img src="/images/loaduai.gif" width=23/>  正在努力加載中...');

                   $('#loadmore').attr('disabled','disabled');

            },

            success : function(data){

            if(data){

                $("#showajaxnews").append(data);

                $("#loadmore").removeAttr('disabled');

               $("#loadmore").html('點擊加載更多');

                i++;

            }else{

                $("#loadmore").show().html("已全部加載完畢!");

                $('#loadmore').attr('disabled','disabled');

                return false;

            }     

            }

        });

    });

});

</script>

 

 

列表內容模板(list.var) (*)

<li class='news-list'>

    <a href='[!--news.url--]' title='[!--title--]' class='date-link'>

        <img src='[!--titlepic--]' alt='[!--title--]'  class='date-img-url'/>

        <h4 class='date-title'>[!--title--]</h4><span class='act-datetime'>[!--newstime--]</span>

    </a>

</li>

 

 帝國cms加載更多.zip

文件類型: .zip d5ca9e37153306c577e168598bc4a02d.zip (46.69 KB)
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 桦甸市| 南丹县| 禄丰县| 黔西| 永登县| 广汉市| 临漳县| 汝州市| 房产| 麦盖提县| 当阳市| 长葛市| 永定县| 绩溪县| 桦甸市| 务川| 枣庄市| 武川县| 烟台市| 罗平县| 常熟市| 金川县| 宁强县| 民权县| 布拖县| 康乐县| 上饶市| 民丰县| 商都县| 青龙| 黄龙县| 石屏县| 安康市| 嘉兴市| 元氏县| 阆中市| 山东| 乌鲁木齐县| 同心县| 塘沽区| 阿拉善右旗|