dedecms分类信息内容也为什么上一篇和下一篇都显示没有了?其实上下都有文章的。
在\dede\include\extendfuncphp文件中添加如下函数:
function getArticleList($category=0,$order="",$limit="0,200"){
global $dsql;
$query = "SELECT arc,tptypedir,tptypename,tpcorank,tpisdefault,tpdefaultname,tpnamerule,
tpnamerule2,tpispart,tpmoresite,tpsiteurl,tpsitepath
FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp on arctypeid=tpid
where tpid=$category";
//此sql语句我只加了where判断文章所属分类
//其他的order limit 你根据需要自己添加
$dsql->SetQuery($query);
$dsql->Execute('lit');
$arr = array();
$cnt = 0;
$str = "";
while ($row = $dsql->GetArray('lit')) {
if($cnt%4 == 0){
$str = "<div class='css1'>";
}
if($cnt%4 > 0){
$class = "css3";
}else{
$class = "css2";
}
$str = "<span class='"$class"'>"$row['title']"</span>";
$cnt++;
if($cnt%4 == 0){
$str = "</div>";
}
//$row中可用的常用字段如下:$row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'], row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']
}
return $str;
}
然后在模板中使用
{dede:field name='typeid' function="getArticleList(@me)" /}
将分类的id传给此函数就可以调用到数据,输出就是你要的格式。
输出内容你修改下php文件,常用字段都给你写在注释里了。
如果可以请也将我昨天给你回答的采纳一下。
修改inlcude下的arclistviewclassphp文件
搜索
if($row = $this->dsql->GetArray("al"))
在下面的大括号内添加几行代码
$query = "Select body From `#@__addonarticle`where aid =$row[id] ";
$this->dsql->SetQuery($query);
$this->dsql->Execute();
$temp=$this->dsql->GetArray());
$row['body']=$temp['body'];
然后在直接使用[field:body/]即可
可能不同版本的代码不太一样.你先试试吧
修改文件/include/arcarchivesclass
将以下代码
$next = (is_array($nextR) " where arcid={$nextR['id']} " : ' where 1>2 ');$pre = (is_array($preR) " where arcid={$preR['id']} " : ' where 1>2 ');
$query = "Select arcid,arctitle,arcshorttitle,arctypeid,arcismake,arcsenddate,arcarcrank,arcmoney,arcfilename,arclitpic,
ttypedir,ttypename,tnamerule,tnamerule2,tispart,tmoresite,tsiteurl,tsitepath
from `#@__archives` arc left join #@__arctype t on arctypeid=tid ";
改为如下
if($this->ChannelUnit->ChannelInfos[‘issystem‘]!=-1){$next = (is_array($nextR) " where arcid={$nextR[‘id‘]} " : ‘ where 1>2 ‘);
$pre = (is_array($preR) " where arcid={$preR[‘id‘]} " : ‘ where 1>2 ‘);
$query = "Select arcid,arctitle,arcshorttitle,arctypeid,arcismake,arcsenddate,arcarcrank,arcmoney,arcfilename,arclitpic,
ttypedir,ttypename,tnamerule,tnamerule2,tispart,tmoresite,tsiteurl,tsitepath
from `#@__archives` arc left join #@__arctype t on arctypeid=tid ";
}else{
$next = (is_array($nextR) " where arcaid={$nextR[‘id‘]} " : ‘ where 1>2 ‘);
$pre = (is_array($preR) " where arcaid={$preR[‘id‘]} " : ‘ where 1>2 ‘);
$query = "Select arcaid,arctitle,arctypeid,arcsenddate,arcarcrank,arclitpic,
ttypedir,ttypename,tnamerule,tnamerule2,tispart,tmoresite,tsiteurl,tsitepath
from `"$this->ChannelUnit->ChannelInfos[‘addtable‘]"` arc left join #@__arctype t on arctypeid=tid ";
}
0条评论