下面教大家怎么自己開(kāi)發(fā)一個(gè)織夢(mèng)標(biāo)簽來(lái)調(diào)用當(dāng)前作者的所有文章。
首先將以下函數(shù)放到 include/extend.func.php 最下邊,這個(gè)函數(shù)是用來(lái)獲取靜態(tài)頁(yè)面的URL地址的。
function GetOneDocUrl($aid) { global $dsql; include_once(DEDEINC."/channelunit.func.php"); $aid = trim(ereg_replace('[^0-9]','',$aid)); $chRow = $dsql->GetOne("Select arc.*,ch.maintable,ch.addtable,ch.issystem From `dede_arctiny` arc left join `dede_channeltype` ch on ch.id=arc.channel where arc.id='$aid' "); if(!is_array($chRow)) { return $reArr; } else { if(empty($chRow['maintable'])) $chRow['maintable'] = 'dede_archives'; } if($chRow['issystem']!=-1) { $nquery = " Select arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath From `{$chRow['maintable']}` arc left join `dede_arctype` tp on tp.id=arc.typeid where arc.id='$aid' "; } else { $nquery = " Select arc.*,1 as ismake,0 as money,'' as filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath From `{$chRow['addtable']}` arc left join `dede_arctype` tp on tp.id=arc.typeid where arc.aid='$aid' "; } $arcRow = $dsql->GetOne($nquery); $Url = GetFileUrl($aid,$arcRow['typeid'],$arcRow['senddate'],$reArr['title'],$arcRow['ismake'],$arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],$arcRow['filename'],$arcRow['moresite'],$arcRow['siteurl'],$arcRow['sitepath']); return $Url; } |
然后將以下代碼保存為 diary.lib.php 放到include/taglib 目錄下
<?php /** * 調(diào)用當(dāng)前作者文檔 * @version $Id: diary.lib.php 1:37 2015年6月2日 by 織夢(mèng)無(wú)憂 * @link http://www.dedecms51.com */ if(!defined('DEDEINC')){ exit("Request Error!"); } function lib_diary(&$ctag,&$refObj) { global $dsql,$envs; $jjmhk="row|1,typeid|0"; FillAttsDefault($ctag->CAttribute->Items,$jjmhk); extract($ctag->CAttribute->Items); $innertext = trim($ctag->GetInnerText()); $ctp = new DedeTagParse(); $ctp->SetNameSpace('field','[',']'); $ctp->LoadSource($innertext); $writer = $ctag->GetAtt('writer'); if($writer=='this') { $writer = isset($refObj->Fields['writer']) ? $refObj->Fields['writer'] : 0; } $query = "select a.id,a.title,a.writer,a.pubdate,a.typeid,b.aid from dede_archives a LEFT JOIN dede_addonarticle b on b.aid=a.id where a.typeid='{$typeid}' and a.writer='{$writer}' order by a.pubdate desc LIMIT 0,$row"; $dsql->SetQuery($query); $dsql->Execute('me',$query); while($rs= $dsql->GetArray('me')) { $rs['pubdate']=GetDateMK($rs['pubdate']); $rs['arcurl']=GetOneDocUrl($rs['id']); $rs['title'] = 0 == $titlelen?$rs['title']:cn_substr($rs['title'], $titlelen); $ctp->LoadSource($innertext); foreach($ctp->CTags as$tagid=>$ctag) { if(!empty($rs[strtolower($ctag->GetName())])) { $ctp->Assign($tagid,$rs[$ctag->GetName()]); } } $revalue.= $ctp->GetResult(); } return $revalue; } |
最后再內(nèi)容頁(yè)的模板中調(diào)用以下標(biāo)簽,下邊的li span 標(biāo)簽 自己修改刪除。
{dede:diary row='10' typeid='2' writer='this'}
<li><a href="[field:arcurl/]">[field:title/]</a><span class="p-l5">([field:pubdate/])</span></li>
{/dede:diary}
==============================分割線============================
標(biāo)簽說(shuō)明:
row= 調(diào)用條數(shù)
typeid= 調(diào)用欄目ID
writer= 默認(rèn) this 無(wú)需修改
效果圖:
版權(quán)聲明: 本站資源均來(lái)自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: 織夢(mèng)二次開(kāi)發(fā)調(diào)用當(dāng)前作者文檔的標(biāo)簽