上面没人 發表於 2024-1-21 00:00:00

DEDECMS系统分页标签自定义二次开发实例

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        本文实例讲述了DEDECMS系统分页标签自定义二次开发的方法。分享给大家供大家参考。具体实现方法如下:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        自定搜索结果页面文章分页,在/plus文件夹中新建一个search.php文件,代码如下:<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode4" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        &lt;?php <br>
        require_once(dirname(__FILE__)."/../include/common.inc.php"); <br>
        require_once(DEDEINC."/datalistcp.class.php"); <br><br>
        $dlist=new DataListCP(); <br>
        $dlist-&gt;pageSize=5; <br><br>
        $tplfile=DEDEROOT.'/templets/movie/search.htm'; <br>
        $dlist-&gt;SetTemplate($tplfile); <br><br>
        //选取影视模型的所有文档 <br>
        $sql="select z.*,f.* from dede_archives as z right join dede_addonmovie as f on z.id=f.aid"; <br>
        $dlist-&gt;SetSource($sql); <br><br>
        $dlist-&gt;Display(); <br>
        ?&gt;</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>search.htm模板文件,代码如下:</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode5" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        {dede:datalist} <br>
        &lt;li class="x&lt;?php echo ++$step;?&gt;"&gt; <br>
        &lt;a href="#" target="_blank"&gt;&lt;img src="{dede:field.litpic/}" /&gt;&lt;/a&gt; <br>
        &lt;p&gt;{dede:field.language/}&lt;/p&gt; <br>
        &lt;div&gt;&lt;a href="#" target="_blank"&gt;{dede:field.title/}&lt;/a&gt; &lt;img src="{dede:global.cfg_templets_skin/}/images/1.jpg" /&gt; &lt;em&gt;{dede:field.pfz/}分&lt;/em&gt;&lt;/div&gt; <br>
        &lt;/li&gt; <br>
        {/dede:datalist} <br>
        &lt;div class="pages"&gt; <br>
        &lt;div&gt;{dede:pagelist/}&lt;/div&gt; <br>
        &lt;/div&gt;</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>{dede:datalist}标签中可以嵌套使用{dede:field.字段名/}</span>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        {dede:datalist}标签中不好使用.</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        检索的模板文件中可以直接使用&lt;?php ?&gt;代码,检索模板文件可以使用 &lt;?php echo  $fields['字段名']; ?&gt;来取出字段信息.</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        dede自定义留言分页,在/include文件夹中新建一个message_list.php文件,代码如下:<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode6" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        &lt;?php <br>
        require_once 'include/common.inc.php'; <br>
        require_once(DEDEINC.'/datalistcp.class.php'); <br>
        //读取留言列表 <br>
        $dl = new DataListCP(); <br>
        $dl-&gt;pageSize = 10; //设定每页显示记录数(默认25条) <br>
        // $dl-&gt;SetParameter($key,$value); //设定get字符串的变量 <br>
        //这两句的顺序不能更换 <br>
        if(emptyempty($s_tmplets)) { <br>
        $s_tmplets = '/default/message_list.htm'; <br>
        $tplfile = DEDETEMPLATE.$s_tmplets; <br>
        $dl-&gt;SetTemplate($tplfile); //载入模板 <br>
        $sql = "SELECT * FROM acne_diyform2 where ifcheck=1"; //自定义 <br>
        $dl-&gt;SetSource($sql); //设定查询SQL <br>
        $dl-&gt;Display(); //显示 <br>
        $dl-&gt;Close(); <br>
        } <br>
        ?&gt;</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>在对应的模板中写入如下代码:</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode7" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        {dede:datalist} <br>
        &lt; div class=”bottom_ask”&gt; <br>
        &lt;p&gt;{dede:field.message/}&lt;/p&gt; <br>
        &lt;/div&gt; <br>
        &lt; div class=”bottom_answer”&gt; <br>
        &lt;p&gt;{dede:field.reply/}&lt;/p&gt; <br>
        &lt;/div &gt; <br>
        {/dede:datalist } <br>
        &lt;ul &gt; <br>
        {dede:pagelist listsize='2' listitem='info index pre pageno next end option'/} <br>
        &lt;/ul &gt;</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>这样就能调用一个自定义表单,并且有分页的数据了</span>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        希望本文所述对大家的dedecms建站有所帮助。</p>
頁: [1]
查看完整版本: DEDECMS系统分页标签自定义二次开发实例