梅花谷 發表於 2023-7-12 00:00:00

织梦dedecms调用得到文章所属的副栏目id及副栏目名称的教程

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        标签调用代码</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:xhtml;">
{dede:arclist row='2' titlelen='100'typeid=2 orderby='id' }
      &lt;span&gt;
      &lt;ahref="javascript:"onclick="javascript:change_tab();"&gt;&lt;/a&gt;
      &lt;!-- 上面是文章所属的主栏目,很方便调用. --&gt;
      
      &lt;!-- 上面是文章所属的副栏目,需要单独写函数get_url_by_typeid2 --&gt;
      &lt;/span&gt;
{/dede:arclist}
</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        函数代码,在includeextend.func.php 中增加如下代码:</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:php;toolbar:false;">
//得到副栏目信息,并组织字符串
function get_url_by_typeid2($typeid2){
      $arrs=explode(",",$typeid2);//解析副栏目字段
      if($typeid2==0){
      return '';
      }else{
      $url='';
      foreach($arrs as $v){
            $url.='&lt;a href="javascript:"
            onclick="javascript:change_tab('.$v.');"&gt;'.get_typename($v).'&lt;/a&gt;';
      }
      return $url;
      }
}
//织梦根据栏目编号typeid调用typename栏目名
function get_typename($typeid){
    global $dsql;
    $rs=$dsql-&gt;getOne("select typename from arctype where id='$typeid'");
return $rs['typename'];
}
</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        注意:织梦标签artlist不能调用副栏目中的文章内容的问题,即文章属于互联网这个副栏目,但互联网栏目中却不显示这个文章。需要修改系统文件./include/taglib/arclist.lib.php。</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:php;toolbar:false;">
if($CrossID=='') $orwheres[] = ' arc.typeid IN ('.GetSonIds($typeid).')';
else $orwheres[] = ' arc.typeid IN ('.GetSonIds($typeid).','.$CrossID.')';
</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        修改为</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:php;toolbar:false;">
if($CrossID=='')
$orwheres[] = " (arc.typeid in (".GetSonIds($typeid).") or arc.typeid2 in (".GetSonIds($typeid).") or CONCAT( ',', arc.typeid2, ',' ) LIKE '%,".$typeid.",%' )";
else
$orwheres[] = " (arc.typeid in (".GetSonIds($typeid).",".$CrossID.") or arc.typeid2 in (".GetSonIds($typeid).",".$CrossID.") or CONCAT( ',', arc.typeid2, ',' ) LIKE '%,".$typeid.",%')";</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁: [1]
查看完整版本: 织梦dedecms调用得到文章所属的副栏目id及副栏目名称的教程