大漠芭蕾 發表於 2023-6-13 00:00:00

DEDECMS调用特定ID文章内容的实现方法

<p>
        <strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>方法一: </strong><br><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>找到:include\inc_arcpart_view.php文件,在里面找到第function ParseTemplet();这一个函数里面的 </span></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";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" 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";'>
        <br>
        〔 <br>
        $this-&gt;dtp-&gt;Assign($tagid, <br>
        $this-&gt;GetArcList($typeid,$ctag-&gt;GetAtt("row"),$ctag-&gt;GetAtt("col"), <br>
        $titlelen,$infolen,$ctag-&gt;GetAtt("imgwidth"),$ctag-&gt;GetAtt("imgheight"), <br>
        $ctag-&gt;GetAtt("type"),$orderby,$ctag-&gt;GetAtt("keyword"),$innertext, <br>
        $ctag-&gt;GetAtt("tablewidth"),0,"",$channelid,$ctag-&gt;GetAtt("limit"),$ctag-&gt;GetAtt("att"), <br>
        $ctag-&gt;GetAtt("orderway"),$ctag-&gt;GetAtt("subday"),$autopartid,$ctag-&gt;GetAtt("ismember") <br>
        ) <br>
        〕 </p>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>将里面的红色的0改为$ctag-&gt;GetAtt('arcid'),就行了,然后到incclude\inc\inc_fun_spgetarclist.php文件里面找到 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>〔if($arcid!=0) $orwhere .= " And arc.ID&lt;&gt;'$arcid' ";〕 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>将这一句改为:if($arcid!=0) $orwhere .= " And arc.ID='$arcid' "; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>if($arcid==0) $orwhere .= " And arc.ID&lt;&gt;'$arcid' "; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>以上两句,替换掉上面需要替换的语句。然后就可以调用了:如在主页中调用ID号为145的文章内容: </span></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";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" 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";'>
        <br>
        {dede:arclist arcid='145' row='5' col='1' titlelen='24' } <br>
        &lt;table width='100%' border='0' cellspacing='2' cellpadding='2'&gt; <br>
        &lt;tr&gt; <br>
        &lt;td&gt; <br>
        &lt;/td&gt; <br>
        &lt;/tr&gt; <br>
        &lt;/table&gt; <br>
        {/dede:arclist} </p>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>这样就只会调用到一个ID为145的文章,即始ROW设为5也没有用,因为从数据库里面只提出一条记录来, </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>但是现在还不能解析HTML语法,提出来的文章没有版式,下次改进。 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>方法二: </strong><br><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>刚一开始没有仔细看论坛,所以自已写出这样的方法,其实大可不必按以上的方法做,可以借助强大的LOOP来实现这一种需求,现将个人方法写在下面,希望对需要的人有帮助; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>在首页模板里面加入如下代码: </span></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";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" 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";'>
        <br>
        {dede:loop table='dede_addonarticle' sort='aid' row='8' if='aid=524'} <br>
         <br>
        &lt;hr&gt; <br>
         <br>
        {/dede:loop} </p>
<p>
        <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;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>{dede:loop table='dede_addonarticle' sort='aid' row='8' if='aid=524'} </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>其中有一个aid=524代表要取文章列表的ID号为524的文章, </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>table='dede_addonarticle' 为所存文章的表 </span><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;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'> </span><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;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>如:将得到文章所有的内容,不过滤HTML标记 </span><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;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>只取内容的前200个字符 </span><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;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>取前200个字符并把HTML标记过滤 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>其实DEDECMS真的很强大,偶算是领教了。</span></p>
頁: [1]
查看完整版本: DEDECMS调用特定ID文章内容的实现方法