DedeCms分类信息联动筛选,省级与地市分开联动,注意:只适用于5.6版,其它版本没有测试,只应用于分类信息模型。其它联动可参照修改。
可能标题说的不是很清楚,下面以图为示例:
如上图所示,默认是显示北京的区县,当点击上海市时,地市处显示上海的县区。这下大家伙明白了吧!
现在开始代码修改 *** 作,只需要修改一个文件。
打开/include/taglib/infolink.lib.php,找到:
Copy to Clipboard引用的内容:[www.dede58.com]//地区链接 if(empty($nativeplace)) { foreach($em_nativeplaces as $eid=>$em) { if($eid % 500 != 0) continue; $fields['nativeplace'] .= " {$em}rn"; } } else { $sontype = ( ($nativeplace % 500 != 0) ? $nativeplace : 0 ); $toptype = ( ($nativeplace % 500 == 0) ? $nativeplace : ( $nativeplace-($nativeplace%500) ) ); $fields['nativeplace'] = "{$em_nativeplaces[$toptype]} >> "; foreach($em_nativeplaces as $eid=>$em) { if($eid < $toptype+1 || $eid > $toptype+499) continue; if($eid == $nativeplace) { $fields['nativeplace'] .= " {$em}rn"; } else { $fields['nativeplace'] .= " {$em}rn"; } } }
把上面注释掉,然后在下面添加如下代码:
Copy to ClipboardLiehuo.Net Codes引用的内容:[www.dede58.com] foreach($em_nativeplaces as $eid=>$em) { if($eid % 500 != 0) continue; $fields['nativeplace'] .= " {$em}rn"; } //地区链接 if(empty($nativeplace)) { foreach($em_nativeplaces as $eid=>$em) { if($eid > 999 ) continue; $fields['diqu'] .= " {$em}rn"; } } else { $sontype = ( ($nativeplace % 500 != 0) ? $nativeplace : 0 ); $toptype = ( ($nativeplace % 500 == 0) ? $nativeplace : ( $nativeplace-($nativeplace%500) ) ); foreach($em_nativeplaces as $eid=>$em) { if($eid < $toptype+1 || $eid > $toptype+499) continue; if($eid == $nativeplace) { $fields['diqu'] .= " {$em}rn"; } else { $fields['diqu'] .= " {$em}rn"; } } }
保存就可以了。谢谢阅读烈火网提供的DedeCMS教程。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)