自定义联动类别是一种非常实用的功能,可以满足不同网站的个性化需求。以下是如何实现自定义联动类别的详细步骤。如果您在操作过程中遇到问题,欢迎随时交流和改进。

首先,需要对include\\taglib\\infolink.lib.php文件进行修改:


require_once(DEDEROOT.'/data/enums/infotype.php');
// 添加以下代码
require_once(DEDEROOT.'/data/enums/自定义联动类别字段名.php');

接下来,在function lib_infolink(&$ctag,&$refObj)中添加如下内容:


global $dsql, $nativeplace, $infotype, $自定义联动类别字段名, $hasSetEnumJs, $cfg_cmspath, $cfg_mainsite;
global $em_nativeplaces, $em_infotypes, $em_自定义联动类别字段名s;

$fields = array(
    'nativeplace' => '', 
    'infotype' => '', 
    '自定义联动类别字段名' => '', 
    'typeid' => $typeid,
    'channelid' => $channelid,
    'linkallplace' => '',
    'linkealltype' => '',
    'linkeall自定义联动类别字段名' => ''
);

$fields['linkalltype'] = "不限";
// 添加以下代码
$fields['linkeall自定义联动类别字段名'] = "不限";

搜索if(is_array($ctp->CTags)),在其上方添加以下代码:


if(empty($自定义联动类别字段名)) {
    foreach($em_自定义联动类别字段名s as $eid => $em) {
        if($eid % 500 != 0) continue;
        $fields['自定义联动类别字段名'] .= " {$em}";
    }
} else {
    $sontype = (($自定义联动类别字段名 % 500 != 0) ? $自定义联动类别字段名 : 0);
    $toptype = (($自定义联动类别字段名 % 500 == 0) ? $自定义联动类别字段名 : ($自定义联动类别字段名 - ($membertypeP0)));
    $fields['自定义联动类别字段名'] = "{$em_自定义联动类别字段名s[$toptype]} ";
    foreach($em_自定义联动类别字段名s as $eid => $em) {
        if($eid < $toptype + 1 || $eid > $toptype + 499) continue;
        if($eid == $自定义联动类别字段名) {
            $fields['自定义联动类别字段名'] .= " {$em}";
        } else {
            $fields['自定义联动类别字段名'] .= " {$em}";
        }
    }
}

然后,修改plus\\list.php文件:


$infotype = ((empty($infotype) || !is_numeric($infotype)) ? 0 : $infotype);
// 添加以下代码
$自定义联动类别字段名 = ((empty($自定义联动类别字段名) || !is_numeric($自定义联动类别字段名)) ? 0 : $自定义联动类别字段名);

if(!empty($infotype)) $cArr['infotype'] = $infotype;
// 添加以下代码
if(!empty($自定义联动类别字段名)) $cArr['自定义联动类别字段名'] = $自定义联动类别字段名;

最后,打开include\\arc.sglistview.class.php文件,找到if(!empty($this->searchArr['keyword'])),在其上方添加以下代码:


if(!empty($this->searchArr['自定义联动类别字段名'])) {
    if($this->searchArr['自定义联动类别字段名'] % 500 == 0 ) {
        $naddQuery .= " And arc.自定义联动类别字段名 >= '{$this->searchArr['自定义联动类别字段名']}' And arc.自定义联动类别字段名 < '".($this->searchArr['自定义联动类别字段名']+500)."'";
    } else {
        $naddQuery .= "And arc.自定义联动类别字段名 = '{$this->searchArr['自定义联动类别字段名']}'";
    }
}

完成上述修改后,您可以在模板中通过以下标签调用:


[field:linkeall自定义联动类别字段名/] [field:自定义联动类别字段名 /]

以上方法可以帮助您实现自定义联动类别的功能。如果有任何疑问或建议,请随时提出!