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";'>
<?php <br>
require_once(dirname(__FILE__)."/../include/common.inc.php"); <br>
require_once(DEDEINC."/datalistcp.class.php"); <br><br>
$dlist=new DataListCP(); <br>
$dlist->pageSize=5; <br><br>
$tplfile=DEDEROOT.'/templets/movie/search.htm'; <br>
$dlist->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->SetSource($sql); <br><br>
$dlist->Display(); <br>
?></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>
<li class="x<?php echo ++$step;?>"> <br>
<a href="#" target="_blank"><img src="{dede:field.litpic/}" /></a> <br>
<p>{dede:field.language/}</p> <br>
<div><a href="#" target="_blank">{dede:field.title/}</a> <img src="{dede:global.cfg_templets_skin/}/images/1.jpg" /> <em>{dede:field.pfz/}分</em></div> <br>
</li> <br>
{/dede:datalist} <br>
<div class="pages"> <br>
<div>{dede:pagelist/}</div> <br>
</div></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";'>
检索的模板文件中可以直接使用<?php ?>代码,检索模板文件可以使用 <?php echo $fields['字段名']; ?>来取出字段信息.</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";'>
<?php <br>
require_once 'include/common.inc.php'; <br>
require_once(DEDEINC.'/datalistcp.class.php'); <br>
//读取留言列表 <br>
$dl = new DataListCP(); <br>
$dl->pageSize = 10; //设定每页显示记录数(默认25条) <br>
// $dl->SetParameter($key,$value); //设定get字符串的变量 <br>
//这两句的顺序不能更换 <br>
if(emptyempty($s_tmplets)) { <br>
$s_tmplets = '/default/message_list.htm'; <br>
$tplfile = DEDETEMPLATE.$s_tmplets; <br>
$dl->SetTemplate($tplfile); //载入模板 <br>
$sql = "SELECT * FROM acne_diyform2 where ifcheck=1"; //自定义 <br>
$dl->SetSource($sql); //设定查询SQL <br>
$dl->Display(); //显示 <br>
$dl->Close(); <br>
} <br>
?></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>
< div class=”bottom_ask”> <br>
<p>{dede:field.message/}</p> <br>
</div> <br>
< div class=”bottom_answer”> <br>
<p>{dede:field.reply/}</p> <br>
</div > <br>
{/dede:datalist } <br>
<ul > <br>
{dede:pagelist listsize='2' listitem='info index pre pageno next end option'/} <br>
</ul ></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]