您的位置:首页 > 其它

dede新建模型中自定义联动类别调用及修改方法

2016-03-21 11:02 513 查看
http://www.68cpu.com/index.php/opensourcecms/dedecms/1656.html搜索了好久,没找到一个好的方法,就凑活用这个方法吧。也许只有这个方法比较好
先在后台的“联动类别管理”里新增“类别组”,“类 别 名”填中文,“缓存组名”填英文字母。


在“分类名称”后面增加分类



然后在“内容模型管理”里点“分类信息”,在点“字段管理”,点“添加新字段”。“表单提示文字”填中文,“字段名称”填英文字母

这样,在分类信息里添加文字的时候就有对应的选择了。
然后就是在前台显示。
先修改 include\taglib\infolink.lib.php 文件
搜索require_once(DEDEDATA.'/enums/infotype.php');
下面添加

1de checkedbycsshelper="true" >require_once(DEDEROOT.'/data/enums/自定义联动类别字段名.php');de>
修改

1
2
3
4
de checkedbycsshelper="true" >function
lib_infolink(&$ctag,&$refObj)de>
de checkedbycsshelper="true" >{de>
de checkedbycsshelper="true" > de>de checkedbycsshelper="true" >global
$dsql,$nativeplace,$infotype,$自定义联动类别字段名,$hasSetEnumJs,$cfg_cmspath,$cfg_mainsite;de>
de checkedbycsshelper="true" > de>de checkedbycsshelper="true" >global
$em_nativeplaces,$em_infotypes,$em_自定义联动类别字段名s;
//看清楚,这里后面的个sde>
搜索$fields =
array('nativeplace'=>'','infotype'=>''
修改

1
2
3
4
de checkedbycsshelper="true" >$fields =
array('nativeplace'=>'','infotype'=>'','自定义联动类别字段名'=>'','typeid'=>$typeid,de>
de checkedbycsshelper="true" > de>de checkedbycsshelper="true" >'channelid'=>$channelid,'linkallplace'=>'','linkalltype'=>'','linkall自定义联动类别字段名'=>'');de>
de checkedbycsshelper="true" > de>
de checkedbycsshelper="true" >$fields['nativeplace'] = $fields['infotype'] =
$fields['自定义联动类别字段名'] =
'';de>
搜索$fields['linkalltype'] =
在下面添加

ortant; height: 18px !important;" checkedbycsshelper="true" >

de" jquery="19" checkedbycsshelper="true" >

de" jquery="23" checkedbycsshelper="true" >

ortant; MIN-HEIGHT: 16.8px !important;" jquery="29" checkedbycsshelper="true" >
$fields['linkall自定义联动类别字段名'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动类别字段名={$自定义联动类别字段名}'>不限</a>";

ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" >
1
ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" >$fields['linkall自定义联动类别字段名'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动类别字段名={$自定义联动类别字段名}'>不限</a>";
搜索if(is_array($ctp->CTags))在这句上面添加

ortant; height: 18px !important;" checkedbycsshelper="true" >

de" jquery="44" checkedbycsshelper="true" >

de" jquery="48" checkedbycsshelper="true" >

ortant; MIN-HEIGHT: 16.8px !important;" jquery="54" checkedbycsshelper="true" >
//自定义联动类别字段链接
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}'>{$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}'><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}'>{$em}</a>";
}
}
}

ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" >
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" > //自定义联动类别字段链接 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}'>{$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}'><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}'>{$em}</a>"; } } }
再修改plus\list.php文件
搜索$infotype = ( (empty($infotype) ||
!is_numeric($infotype)) ? 0 : $infotype );在下面添加一句

ortant; height: 18px !important;" checkedbycsshelper="true" >

de" jquery="71" checkedbycsshelper="true" >

de" jquery="75" checkedbycsshelper="true" >

ortant; MIN-HEIGHT: 16.8px !important;" jquery="81" checkedbycsshelper="true" >
$自定义联动类别字段名 = ( (empty($自定义联动类别字段名) || !is_numeric($自定义联动类别字段名)) ? 0 : $自定义联动类别字段名 );

ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" >
1
ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" >$自定义联动类别字段名 = ( (empty($自定义联动类别字段名) || !is_numeric($自定义联动类别字段名)) ? 0 : $自定义联动类别字段名 );
再搜索if(!empty($infotype)) $cArr['infotype'] =
$infotype;,在下面添加

ortant; height: 18px !important;" checkedbycsshelper="true" >

de" jquery="96" checkedbycsshelper="true" >

de" jquery="100" checkedbycsshelper="true" >

ortant; MIN-HEIGHT: 16.8px !important;" jquery="106" checkedbycsshelper="true" >
if(!empty($自定义联动类别字段名)) $cArr['自定义联动类别字段名'] = $自定义联动类别字段名;

ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" >
1
ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" >if(!empty($自定义联动类别字段名)) $cArr['自定义联动类别字段名'] = $自定义联动类别字段名;
找到include\arc.sglistview.class.php文件
搜索if(!empty($this->searchArr['keyword']))在上面添加

ortant; height: 18px !important;" checkedbycsshelper="true" >

de" jquery="121" checkedbycsshelper="true" >

de" jquery="125" checkedbycsshelper="true" >

ortant; MIN-HEIGHT: 16.8px !important;" jquery="131" checkedbycsshelper="true" >
//自定义联动类别

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

ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" >
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" > //自定义联动类别 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['自定义联动类别字段名']}'"; } }
前台模板调用

ortant; height: 18px !important;" checkedbycsshelper="true" >

de" jquery="148" checkedbycsshelper="true" >

de" jquery="152" checkedbycsshelper="true" >

ortant; MIN-HEIGHT: 16.8px !important;" jquery="158" checkedbycsshelper="true" >
[field:linkall自定义联动类别字段名/] [field:自定义联动类别字]

ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" >
1
ortant; FONT-SIZE: 12px !important;" checkedbycsshelper="true" >[field:linkall自定义联动类别字段名/] [field:自定义联动类别字]
阅读 68cpu 的其他文章

上一篇: 瀑布流 淘宝客
DEDECMS织梦模板
下一篇:
浅淡HTML5移动Web开发

[/i]


分享到

分享到:

正在加载中...

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: