张恒硕 發表於 2023-6-10 00:00:00

DEDECMS自定义联动类别调用及修改方法

<p>
        <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;'>[ post] </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>先修改 include\taglib\infolink.lib.php 文件 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>require_once(DEDEROOT.'/data/enums/infotype.php'); </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;'>require_once(DEDEROOT.'/data/enums/自定义联动类别字段名.php'); </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>function lib_infolink(&amp;$ctag,&amp;$refObj) </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;'>global $dsql,$nativeplace,$infotype,$自定义联动类别字段名,$hasSetEnumJs,$cfg_cmspath,$cfg_mainsite; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>global $em_nativeplaces,$em_infotypes,$em_自定义联动类别字段名s; //看清楚,这里后面的个S </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>$fields = array('nativeplace'=&gt;'','infotype'=&gt;'','自定义联动类别字段名'=&gt;'','typeid'=&gt;$typeid, </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>'channelid'=&gt;$channelid,'linkallplace'=&gt;'','linkealltype'=&gt;'','linkeall自定义联动类别字段名'=&gt;''); </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>$fields['nativeplace'] = $fields['infotype'] = $fields['自定义联动类别字段名'] = ''; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>$fields['linkalltype'] = "&lt;a href='{$baseurl}plus/list.php?channelid={$channelid}&amp;tid={$typeid}&amp;nativeplace={$nativeplace}'&gt;不限&lt;/a&gt;"; </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;'>$fields['linkeall自定义联动类别字段名'] = "&lt;a href='{$baseurl}plus/list.php?channelid={$channelid}&amp;tid={$typeid}&amp;自定义联动类别字段名={$自定义联动类别字段名}&amp;nativeplace={$nativeplace}'&gt;不限&lt;/a&gt;"; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>搜索 if(is_array($ctp-&gt;CTags)) 在这句上面添加 </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>
        if(empty($自定义联动类别字段名)) <br>
        { <br>
        foreach($em_自定义联动类别字段名s as $eid=&gt;$em) <br>
        { <br>
        if($eid % 500 != 0) continue; <br>
        $fields['自定义联动类别字段名'] .= " &lt;a href='{$baseurl}plus/list.php?channelid={$channelid}&amp;tid={$typeid}&amp;自定义联动类别字段名={$eid}&amp;nativeplace={$nativeplace}'&gt;{$em}&lt;/a&gt;"; <br>
        } <br>
        } <br>
        else <br>
        { <br>
        $sontype = ( ($自定义联动类别字段名 % 500 != 0) ? $自定义联动类别字段名 : 0 ); <br>
        $toptype = ( ($自定义联动类别字段名 % 500 == 0) ? $自定义联动类别字段名 : ( $自定义联动类别字段名-($membertype%500) ) ); <br>
        $fields['自定义联动类别字段名'] = "&lt;a href='{$baseurl}plus/list.php?channelid={$channelid}&amp;tid={$typeid}&amp;自定义联动类别字段名={$toptype}&amp;nativeplace={$nativeplace}'&gt;&lt;b&gt;{$em_自定义联动类别字段名s[$toptype]}&lt;/b&gt;&lt;/a&gt; "; <br>
        foreach($em_自定义联动类别字段名s as $eid=&gt;$em) <br>
        { <br>
        if($eid &lt; $toptype+1 || $eid &gt; $toptype+499) continue; <br>
        if($eid == $自定义联动类别字段名) { <br>
        $fields['自定义联动类别字段名'] .= " &lt;b&gt;{$em}&lt;/b&gt;"; <br>
        } <br>
        else { <br>
        $fields['自定义联动类别字段名'] .= " &lt;a href='{$baseurl}plus/list.php?channelid={$channelid}&amp;tid={$typeid}&amp;自定义联动类别字段名={$eid}&amp;nativeplace={$nativeplace}'&gt;{$em}&lt;/a&gt;"; <br>
        } <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;'>再修改 plus\list.php 文件 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>搜索 $infotype = ( (empty($infotype) || !is_numeric($infotype)) ? 0 : $infotype ); 在下面添加一句 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>$自定义联动类别字段名 = ( (empty($自定义联动类别字段名) || !is_numeric($自定义联动类别字段名)) ? 0 : $自定义联动类别字段名 ); </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>再搜索 if(!empty($infotype)) $cArr['infotype'] = $infotype; </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;'>if(!empty($自定义联动类别字段名)) $cArr['自定义联动类别字段名'] = $自定义联动类别字段名; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>找到 include\arc.sglistview.class.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(!empty($this-&gt;searchArr['keyword'])) 在上面添加 </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>
        if(!empty($this-&gt;searchArr['自定义联动类别字段名'])) <br>
        { <br>
        if($this-&gt;searchArr['自定义联动类别字段名'] % 500 ==0 ) <br>
        { <br>
        $naddQuery .= " And arc.自定义联动类别字段名 &gt;= '{$this-&gt;searchArr['自定义联动类别字段名']}' And arc.自定义联动类别字段名 &lt; '".($this-&gt;searchArr['自定义联动类别字段名']+500)."'"; <br>
        } <br>
        else <br>
        { <br>
        $naddQuery .= "And arc.自定义联动类别字段名 = '{$this-&gt;searchArr['自定义联动类别字段名']}'"; <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;'>模板调用 </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>
頁: [1]
查看完整版本: DEDECMS自定义联动类别调用及修改方法