一、显示二级联动
cscz是字段名称 address是联动菜单名称 可以随意改
代码效果:
<!--按联动菜单搜索--> <!--按联动菜单搜索--> <div class="form-group row"> <label class="col-md-2 control-label">一级联动</label> <div class="col-md-10"> <?php $tp = dr_linkage('address', $params.csxz); if ($tp.pid) { $tp = dr_linkage('address', $tp.pid); } $tpid = $tp.id; $pids = explode(',', $tp.childids); ?> <label><a class="label {if !$params.csxz}label-success{else}label-default{/if}" target="_blank" href="{Router::search_url($params, 'csxz', NULL)}">不限</a></label> <!--调用联动菜单address,pid为动态获取的地区id--> {linkage code=address pid=0} <label><a class="label {if in_array($t.ii, $pids)}label-success{else}label-default{/if}" target="_blank" href="{Router::search_url($params, 'csxz', $t.id)}">{$t.name}</a></label> {/linkage} </div> </div> {if $tp.child} <div class="form-group row"> <label class="col-md-2 control-label">二级联动</label> <div class="col-md-10"> <label><a class="label {if $tpid == dr_linkage('address', $params.csxz, 0, 'id')}label-success{else}label-default{/if}" target="_blank" href="{Router::search_url($params, 'csxz', $tpid)}">不限</a></label> <!--调用联动菜单address,pid为动态获取的地区id--> {linkage code=address pid=$tpid} <label><a class="label {if $t.id==$params.csxz}label-success{else}label-default{/if}" target="_blank" href="{Router::search_url($params, 'csxz', $t.id)}">{$t.name}</a></label> {/linkage} </div> </div> {/if}
代码共享人:https://www.xunruicms.com/user-4310.html
原文地址:https://www.xunruicms.com/wenda/11942.html
二、显示三级联动
<!--按联动菜单搜索--> <div class="form-group row"> <label class="col-md-2 control-label">一级联动</label> <div class="col-md-10"> <?php $tp = dr_linkage('address', $params.csxz); list($a, $b, $c) = explode(',', $tp['pids']); if ($b) { $temp = dr_linkage('address', $b); $b_id = $b; $b = $temp['id']; } if ($c) { $temp = dr_linkage('address', $c); $c_id = $c; $c = $temp['id']; } $apids = explode(',', $tp.pids); if (!$b && $tp.pid==0) { $b = $tp.id; $apids[] = $tp.ii; } if (!$c && $tp.pid==$b_id) { $c = $tp.id; $temp = dr_linkage('address', $c); if (!$temp.child) { unset($c); } } ?> <label><a class="label {if !$params.csxz}label-success{else}label-default{/if}" target="_blank" href="{Router::search_url($params, 'csxz', NULL)}">不限</a></label> <!--调用联动菜单address,pid为动态获取的地区id--> {linkage code=address pid=0} <label><a class="label {if in_array($t.ii, $apids)}label-success{else}label-default{/if}" target="_blank" href="{Router::search_url($params, 'csxz', $t.id)}">{$t.name}</a></label> {/linkage} </div> </div> {if $b} <div class="form-group row"> <label class="col-md-2 control-label">二级联动</label> <div class="col-md-10"> <label><a class="label {if $b == dr_linkage('address', $params.csxz, 0, 'id')}label-success{else}label-default{/if}" target="_blank" href="{Router::search_url($params, 'csxz', $b)}">不限</a></label> <!--调用联动菜单address,pid为动态获取的地区id--> {linkage code=address pid=$b} <label><a class="label {if $t.id==$params.csxz || in_array($t.ii, $apids)}label-success{else}label-default{/if}" target="_blank" href="{Router::search_url($params, 'csxz', $t.id)}">{$t.name}</a></label> {/linkage} </div> </div> {/if} {if $c} <div class="form-group row"> <label class="col-md-2 control-label">三级联动</label> <div class="col-md-10"> <label><a class="label {if $c == dr_linkage('address', $params.csxz, 0, 'id')}label-success{else}label-default{/if}" target="_blank" href="{Router::search_url($params, 'csxz', $c)}">不限</a></label> <!--调用联动菜单address,pid为动态获取的地区id--> {linkage code=address pid=$c} <label><a class="label {if $t.id==$params.csxz}label-success{else}label-default{/if}" target="_blank" href="{Router::search_url($params, 'csxz', $t.id)}">{$t.name}</a></label> {/linkage} </div> </div> {/if}
代码共享人:https://www.xunruicms.com/user-32186.html
原文地址:https://www.xunruicms.com/wenda/12420.html