获取内容资料
综合学习

织梦dedecms教程 织梦dedecms怎么调用自定义联动类型字段

用织梦仿一个房产网站的时候,需要用到联动菜单,在现有的联动基础上只能创建一级和三级栏目,后来研究一下在织梦5.7里边最好是重新创建联动类别,具体步骤可以参考其他教程。本节主要讲一下怎么把添加好的联动类型调用出来,经过测试终于解决了。

把方法分享一下…不对的地方请大家帮助改正

[ post]

先修改 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; //看清楚,这里后面的个S

$fields = array(‘nativeplace’= ”,’infotype’= ”,’自定义联动类别字段名’= ”,’typeid’= $typeid,

‘channelid’= $channelid,’linkallplace’= ”,’linkealltype’= ”,’linkeall自定义联动类别字段名’= ”);

$fields[‘nativeplace’] = $fields[‘infotype’] = $fields[‘自定义联动类别字段名’] = ”;

$fields[‘linkalltype’] = ” a href=https://www.aihao.org/post/'{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}’ 不限“;

//下面添加一行

$fields[‘linkeall自定义联动类别字段名’] = ” a href=https://www.aihao.org/post/'{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动类别字段名={$自定义联动类别字段名}&nativeplace={$nativeplace}’ 不限“;

搜索 if(is_array($ctp- CTags)) 在这句上面添加

复制代码

代码如下:

//自定义联动类别字段链接

if(empty($自定义联动类别字段名))

{

foreach($em_自定义联动类别字段名s as $eid= $em)

{

if($eid % 500 != 0) continue;

$fields[‘自定义联动类别字段名’] .= ” a href=https://www.aihao.org/post/'{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动类别字段名={$eid}&nativeplace={$nativeplace}’ {$em}“;

}

}

else

{

$sontype = ( ($自定义联动类别字段名 % 500 != 0) ? $自定义联动类别字段名 : 0 );

$toptype = ( ($自定义联动类别字段名 % 500 == 0) ? $自定义联动类别字段名 : ( $自定义联动类别字段名-($membertype%500) ) );

$fields[‘自定义联动类别字段名’] = ” a href=https://www.aihao.org/post/'{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动类别字段名={$toptype}&nativeplace={$nativeplace}’ {$em_自定义联动类别字段名s[$toptype]} “;

foreach($em_自定义联动类别字段名s as $eid= $em)

{

if($eid $toptype+1 || $eid $toptype+499) continue;

if($eid == $自定义联动类别字段名) {

$fields[‘自定义联动类别字段名’] .= ” b {$em} /b “;

}

else {

$fields[‘自定义联动类别字段名’] .= ” a href=https://www.aihao.org/post/'{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动类别字段名={$eid}&nativeplace={$nativeplace}’ {$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:自定义联动类别字段名 /]

Similar Posts

发表评论

邮箱地址不会被公开。 必填项已用*标注