1. 首页
  2. 源码

【dedecms织梦教程】DedeCMS V5.7自定义联动字段调用条件筛选解决方法

方法来源:http://bbs.dedecms.com/265155.html 完善版:hinesey 非常感谢原作者的方法,解决了我一部分的疑问。以下是我重新总结的方法! 原作者用的是V5.6版本,和V5.7版本有一点点不同,最初按照原始的方法改了,但发现出错,而且某些地方还不够完善,于是我将每处改过的地方都看了一遍重新编辑过,我的是改进过的完整方法,将不完善的地方都改进了。测试的系统版本是D

方法来源:http://bbs.dedecms.com/265155.html 完善版:hinesey

非常感谢原作者的方法,解决了我一部分的疑问。以下是我重新总结的方法!

原作者用的是V5.6版本,和V5.7版本有一点点不同,最初按照原始的方法改了,但发现出错,而且某些地方还不够完善,于是我将每处改过的地方都看了一遍重新编辑过,我的是改进过的完整方法,将不完善的地方都改进了。测试的系统版本是DedeCMS V5.7(其他版本未测试过),调用页面是自定义内容模型的列表页(这里用到的是list_sale.htm)。

========================================================================================

先归纳一下,要改动的文件有4个(不包括列表页的模板文件),修改前先做好备份。以下所有代码中将“自定义联动字段名”改为你要添加的自定义联动类别的字段名,例如:new_type。

/include/taglib/infOLink.lib.php

/plus/list.php

/include/arc.sglistview.class.php

/include/taglib/infoguIDe.lib.php

========================================================================================

一、修改/include/taglib/infolink.lib.php文件,这个文件需要修改多处,注意看清楚。

1、搜索源代码(约在第26行):

require_once(DEDEDATA.'/enums/infotype.php');

在下面换行加上:

require_once(DEDEDATA.'/enums/自定义联动字段名.php');

2、搜索(约在第30行):

global $dsql,$nativeplace,$infotype,$hasSetEnumJs,$cfg_cmspath,$cfg_mainsite;

global $em_nativeplaces,$em_infotypes;

改为:

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'=>'','linkalltype'=>'','linkeall自定义联动字段名'=>'');

$fields['nativeplace'] = $fields['infotype'] = $fields['自定义联动字段名'] = '';

3、搜索:

$fields = array('nativeplace'=>'','infotype'=>'','typeid'=>$typeid,

'channelid'=>$channelid,'linkallplace'=>'','linkalltype'=>'');

$fields['nativeplace'] = $fields['infotype'] = '';

改为:

$fields = array('nativeplace'=>'','infotype'=>'','自定义联动字段名'=>'','typeid'=>$typeid,

'channelid'=>$channelid,'linkallplace'=>'','linkalltype'=>'','自定义联动字段名'=>'');

$fields['nativeplace'] = $fields['infotype'] = $fields['自定义联动字段名'] = '';

4、搜索(约在第76行):

$fields['linkallplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$infotype}'>不限</a>";

$fields['linkalltype'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}'>不限</a>";

改为:

$fields['linkallplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$infotype}&自定义联动字段名={$自定义联动字段名}'>不限</a>";

$fields['linkalltype'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&自定义联动字段名={$自定义联动字段名}'>不限</a>";

$fields['linkall自定义联动字段名'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$infotype}'>不限</a>";

5、//地区链接,搜索(约在86行):

$fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>/r/n";

改为:

$fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}&自定义联动字段名={$自定义联动字段名}'>{$em}</a>/r/n";

搜索(约在94行):

$fields['nativeplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$toptype}&infotype={$infotype}'> <b>{$em_nativeplaces[$toptype]}</b></a> &gt;&gt; ";

改为:

$fields['nativeplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$toptype}&infotype={$infotype}&自定义联动字段名={$自定义联动字段名}'> <b>{$em_nativeplaces[$toptype]}</b></a> &gt;&gt; ";

搜索(约在102行):

$fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>/r/n";

改为:

$fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}&自定义联动字段名={$自定义联动字段名}'>{$em}</a>/r/n";

6、//小分类链接,搜索(约在119行):

$fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>/r/n";

改为:

$fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}&自定义联动字段名={$自定义联动字段名}'>{$em}</a>/r/n";

搜索(约在127行):

$fields['infotype'] .= "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$toptype}&nativeplace={$nativeplace}'><b>{$em_infotypes[$toptype]}</b></a> &gt;&gt; ";

改为:

$fields['infotype'] .= "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$toptype}&nativeplace={$nativeplace}&自定义联动字段名={$自定义联动字段名}'><b>{$em_infotypes[$toptype]}</b></a> &gt;&gt; ";

搜索(约在134行):

$fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>/r/n";

改为:

$fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}&自定义联动字段名={$自定义联动字段名}'>{$em}</a>/r/n";

7、搜索(约在140行):

if(is_array($ctp->CTags))

在上面换行添加:

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

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

{

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

{

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

$fields['自定义联动字段名'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动字段名={$eid}&nativeplace={$nativeplace}&infotype={$infotype}'>{$em}</a>";

}

}

else

{

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

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

$fields['自定义联动字段名'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动字段名={$toptype}&nativeplace={$nativeplace}&infotype={$infotype}'><b>{$em_自定义联动字段名s[$toptype]}</b></a> ";

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

{

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

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

$fields['自定义联动字段名'] .= " <b>{$em}</b>";

}

else {

$fields['自定义联动字段名'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动字段名={$eid}&nativeplace={$nativeplace}&infotype={$infotype}'>{$em}</a>";

}

}

}

二、修改/plus/list.php文件。

1、搜索(约在39行):

$infotype = ( (empty($infotype) || !is_numeric($infotype)) ? 0 : $infotype );

在下面换行加上:

$自定义联动字段名 = ( (empty($自定义联动字段名) || !is_numeric($自定义联动字段名)) ? 0 : $自定义联动字段名 );

2、搜索(约在44行):

if(!empty($infotype)) $cArr['infotype'] = $infotype;

在下面换行加上:

if(!empty($自定义联动字段名)) $cArr['自定义联动字段名'] = $自定义联动字段名;

三、修改/include/arc.sglistview.class.php文件。

搜索(约在208行):

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['自定义联动字段名']}'";

}

}

四、修改/include/taglib/infoguide.lib.php文件。

搜索(约在80行):

$fields['infotype'] .= '<script language="javascript">MakeTopSelect("infotype", '.$infotype.');</script>'."/r/n";

在下面换行添加:

$fields['自定义联动字段名'] .= "<input type='hidden' id='hidden_自定义联动字段名' name='自定义联动字段名' value='{$自定义联动字段名}' />/r/n";

$fields['自定义联动字段名'] .= "<span class='infosearchtxt'>类型:</span><span id='span_自定义联动字段名'></span>/r/n";

$fields['自定义联动字段名'] .= "<span id='span_自定义联动字段名_son'></span><br />/r/n";

$fields['自定义联动字段名'] .= "<script language='javascript' type='text/javascript' src='{$cfg_mainsite}{$cmspath}data/enums/自定义联动字段名.js'></script>/r/n";

$fields['自定义联动字段名'] .= '<script language="javascript">MakeTopSelect("自定义联动字段名", '.$自定义联动字段名.');</script>'."/r/n";

五、在列表页模板里调用,CSS样式自行修改。

{dede:infolink}

<table id='dedeinfolink'>

<tr>

<td colspan='3' class='iftitle'> 信息附加条件: </td>

</tr>

<tr>

<td width='50'>&nbsp;地 区:</td>

<td align='center' nowrap='yes'>

<div>[field:linkallplace/]</div>

</td>

<td> [field:nativeplace /]&nbsp; </td>

</tr>

<tr>

<td colspan='3' class='spline'>&nbsp;</td>

</tr>

<tr>

<td>&nbsp;类 型:</td>

<td align='center' nowrap='yes'>

<div>[field:linkalltype/]</div>

</td>

<td> [field:infotype /]&nbsp; </td>

</tr>

<tr>

<td colspan='3' class='spline'>&nbsp;</td>

</tr>

<tr>

<td>自定义联动字段名:</td>

<td align='center' nowrap='yes'>

<div>[field:linkall自定义联动字段名/]</div>

</td>

<td> [field:自定义联动字段名 /]&nbsp; </td>

</tr>

<tr>

<td colspan='3' class='spline'>&nbsp;</td>

</tr>

</table>

{/dede:infolink}

六、哎,终于弄完了,好累啊!

hinesey_2012.10.25.

12_20.jpg12_20.jpg
织梦安装教程 通用图文说明https://www.nanrenca.com/5928.html

相关关键词:dede模板|织梦免费模板|免费模板下载|网站源码|织梦模板|Flash网站模板

原创文章,作者:技术宅,如若转载,请注明出处:https://www.nanrenca.com/613.html

发表评论

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

联系我们

400-800-8888

在线咨询:点击这里给我发消息

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息