DedeCms分類信息聯動篩選,省級與地市分開聯動,注意:只適用于5.6版,其它版本沒有測試,只應用于分類信息模型。其它聯動可參照修改。
可能標題說的不是很清楚,下面以圖為示例:
如上圖所示,默認是顯示北京的區縣,當點擊上海市時,地市處顯示上海的縣區。這下大家伙明白了吧!
現在開始代碼修改操作,只需要修改一個文件。
打開/include/taglib/infolink.lib.php,找到:
//地區鏈接 if(empty($nativeplace)) { foreach($em_nativeplaces as $eid=>$em) { if($eid % 500 != 0) continue; $fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>/r/n"; } } else { $sontype = ( ($nativeplace % 500 != 0) ? $nativeplace : 0 ); $toptype = ( ($nativeplace % 500 == 0) ? $nativeplace : ( $nativeplace-($nativeplace%500) ) ); $fields['nativeplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$toptype}&infotype={$infotype}'><b>{$em_nativeplaces[$toptype]}</b></a> >> "; foreach($em_nativeplaces as $eid=>$em) { if($eid < $toptype+1 || $eid > $toptype+499) continue; if($eid == $nativeplace) { $fields['nativeplace'] .= " <b>{$em}</b>/r/n"; } else { $fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>/r/n"; } } } |
把上面注釋掉,然后在下面添加如下代碼:
Copy to ClipboardLiehuo.Net Codes引用的內容:[www.CUOxin.com]foreach($em_nativeplaces as $eid=>$em) { if($eid % 500 != 0) continue; $fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}'>{$em}</a>/r/n"; } //地區鏈接 if(empty($nativeplace)) { foreach($em_nativeplaces as $eid=>$em) { if($eid > 999 ) continue; $fields['diqu'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}'>{$em}</a>/r/n"; } } 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'] .= " <b><a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}'>{$em}</a></b>/r/n"; } else { $fields['diqu'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}'>{$em}</a>/r/n"; } } } |
保存就可以了。謝謝閱讀烈火網提供的DedeCMS教程。
新聞熱點
疑難解答