DEDECMS调用特定ID文章内容的达成方法
发布时间:2022-06-04 14:45:41 所属栏目:经验 来源:互联网
导读:DEDECMS调用特定ID文章内容的达成方法: 方法一: 找到:include/inc_arcpart_view.php文件,在里面找到第function ParseTemplet();这一个函数里面的 复制代码代码如下: 〔 $this-dtp-Assign($tagid, $this-GetArcList($typeid,$ctag-GetAtt(row),$ctag-GetAt
DEDECMS调用特定ID文章内容的达成方法: 方法一: 找到:include/inc_arcpart_view.php文件,在里面找到第function ParseTemplet();这一个函数里面的 复制代码代码如下: 〔 $this->dtp->Assign($tagid, $this->GetArcList($typeid,$ctag->GetAtt("row"),$ctag->GetAtt("col"), $titlelen,$infolen,$ctag->GetAtt("imgwidth"),$ctag->GetAtt("imgheight"), $ctag->GetAtt("type"),$orderby,$ctag->GetAtt("keyword"),$innertext, $ctag->GetAtt("tablewidth"),0,"",$channelid,$ctag->GetAtt("limit"),$ctag->GetAtt("att"), $ctag->GetAtt("orderway"),$ctag->GetAtt("subday"),$autopartid,$ctag->GetAtt("ismember") ) 〕 将里面的红色的0改为$ctag->GetAtt('arcid'),就行了,然后到incclude/inc/inc_fun_spgetarclist.php文件里面找到 〔if($arcid!=0) $orwhere .= " And arc.ID<>'$arcid' ";〕 将这一句改为:if($arcid!=0) $orwhere .= " And arc.ID='$arcid' "; if($arcid==0) $orwhere .= " And arc.ID<>'$arcid' "; 以上两句,替换掉上面需要替换的语句。然后就可以调用了:如在主页中调用ID号为145的文章内容: 复制代码代码如下: {dede:arclist arcid='145' row='5' col='1' titlelen='24' } <table width='100%' border='0' cellspacing='2' cellpadding='2'> <tr> <td>[field:title/] [field:info/]</td> </tr> </table> {/dede:arclist} 这样就只会调用到一个ID为145的文章,即始ROW设为5也没有用,因为从数据库里面只提出一条记录来, 但是现在还不能解析HTML语法,提出来的文章没有版式,下次改进。 方法二: 刚一开始没有仔细看论坛,所以自已写出这样的方法,其实大可不必按以上的方法做,可以借助强大的LOOP来实现这一种需求,现将个人方法写在下面,希望对需要的人有帮助; 在首页模板里面加入如下代码: 复制代码代码如下: {dede:loop table='dede_addonarticle' sort='aid' row='8' if='aid=524'} [field:body/] <hr> [field:body function="Html2Text(cn_substr('@me',200))" /] {/dede:loop} 注意下面的这一行: {dede:loop table='dede_addonarticle' sort='aid' row='8' if='aid=524'} 其中有一个aid=524代表要取文章列表的ID号为524的文章, table='dede_addonarticle' 为所存文章的表 其中中间的这一行最重要, [field:body function="Html2Text(cn_substr('@me',200))" /] 这一句有多种调用方式: 如:[field:body/]将得到文章所有的内容,不过滤HTML标记 [field:body function="(cn_substr('@me',200))" /] 只取内容的前200个字符 [field:body function="Html2Text(cn_substr('@me',200))" /] 取前200个字符并把HTML标记过滤 其实DEDECMS真的很强大,偶算是领教了。 (编辑:牡丹江站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐