帝国CMS结合项多条件筛选可多选
从模型表中取出字段,进行分割。并且判断当前URL是否包含该条件。
下面这段代码是放在模板里面的。
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | <?php $topurl =urldecode( $_SERVER [ "QUERY_STRING" ]); //获取当前URL后缀 $mysql = $empire ->query( "select fvalue from {$dbtbpre}enewsf where f='yxpt'" ); //游戏平台 $r = $empire ->fetch( $mysql ); $rexp = "|" ; $fvalue = explode ( $rexp , $r [ 'fvalue' ]); $count = count ( $fvalue ); for ( $i =0; $i < $count ; $i ++) { $str = "yxpt=" . $fvalue [ $i ]; $strpos = intval ( strpos ( $topurl , $str )); if ( $strpos == "0" ) { $yangshi = ' class="yule_off"' ; } else { $yangshi = ' class="yule_on"' ; } $yxpt .= '<li' . $yangshi . '><a href="' . $public_r [newsurl]. 'e/extend/url/form.php?tempid=3&mid=10&ph=1&yxpt=' . $fvalue [ $i ]. '">' . $fvalue [ $i ]. '</a></li>' ; //当前点击过来的条件 } $mysql = $empire ->query( "select fvalue from {$dbtbpre}enewsf where f='yxlx'" ); //游戏类型 $r = $empire ->fetch( $mysql ); $rexp = "|" ; $fvalue = explode ( $rexp , $r [ 'fvalue' ]); $count = count ( $fvalue ); for ( $i =0; $i < $count ; $i ++) { $str = "yxlx=" . $fvalue [ $i ]; $strpos = intval ( strpos ( $topurl , $str )); if ( $strpos == "0" ) { $yangshi = ' class="yule_off"' ; } else { $yangshi = ' class="yule_on"' ; } $yxlx .= '<li' . $yangshi . '><a href="' . $public_r [newsurl]. 'e/extend/url/form.php?tempid=3&mid=10&ph=1&yxlx=' . $fvalue [ $i ]. '">' . $fvalue [ $i ]. '</a></li>' ; //当前点击过来的条件 } $mysql = $empire ->query( "select fvalue from {$dbtbpre}enewsf where f='aqbz'" ); //安全保障 $r = $empire ->fetch( $mysql ); $rexp = "|" ; $fvalue = explode ( $rexp , $r [ 'fvalue' ]); $count = count ( $fvalue ); for ( $i =0; $i < $count ; $i ++) { $str = "aqbz=" . $fvalue [ $i ]; $strpos = intval ( strpos ( $topurl , $str )); if ( $strpos == "0" ) { $yangshi = ' class="yule_off"' ; } else { $yangshi = ' class="yule_on"' ; } $aqbz .= '<li' . $yangshi . '><a href="' . $public_r [newsurl]. 'e/extend/url/form.php?tempid=3&mid=10&ph=1&aqbz=' . $fvalue [ $i ]. '">' . $fvalue [ $i ]. '</a></li>' ; //当前点击过来的条件 } $mysql = $empire ->query( "select fvalue from {$dbtbpre}enewsf where f='rzzt'" ); //认证评级 $r = $empire ->fetch( $mysql ); $rexp = "|" ; $fvalue = explode ( $rexp , $r [ 'fvalue' ]); $count = count ( $fvalue ); for ( $i =0; $i < $count ; $i ++) { $str = "rzzt=" . $fvalue [ $i ]; $strpos = intval ( strpos ( $topurl , $str )); if ( $strpos == "0" ) { $yangshi = ' class="yule_off"' ; } else { $yangshi = ' class="yule_on"' ; } $xjct .= '<li' . $yangshi . '><a href="' . $public_r [newsurl]. 'e/extend/url/form.php?tempid=3&mid=10&ph=1&rzzt=' . $fvalue [ $i ]. '">' . $fvalue [ $i ]. '</a></li>' ; //当前点击过来的条件 } ?> <div class = "yule_tiaojian" > <div class = "yule_ico_pingtai" ><div class = "yule_ico_01 yule_ico_left" >游戏平台:</div> <div class = "yule_ico_right" > <ul><?= $yxpt ?></ul> </div> </div> <div class = "yule_ico_pingtai" > <div class = "yule_ico_02 yule_ico_left" >游戏类型:</div> <div class = "yule_ico_right" > <ul><?= $yxlx ?></ul> </div> </div> <div class = "yule_ico_pingtai" ><div class = "yule_ico_03 yule_ico_left" >安全保障:</div> <div class = "yule_ico_right" > <ul><?= $aqbz ?></ul> </div> </div> <div class = "yule_ico_pingtai" ><div class = "yule_ico_04 yule_ico_left" >认证评级:</div> <div class = "yule_ico_right" > <ul><?= $xjct ?></ul> </div> </div> </div> |
e/extend/url/form.php 代码如下
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 26 27 | <?php $topurl = $_SERVER [ 'HTTP_REFERER' ]; //获取顶级链接 $strurl = "ph=1" ; $strbh = intval ( strpos ( $topurl , $strurl )); if ( $strbh == "0" ) { $topurl = $public_r [newsurl]. "e/action/ListInfo.php?tempid=3&mid=10&ph=1" ; //判断是否包含当前连接 } $url = $_SERVER [ "QUERY_STRING" ]; //当前URL $rexp = "&" ; $shang = explode ( $rexp , $url ); $count = count ( $shang ); for ( $i =0; $i < $count ; $i ++) { $tiaojian = "&" . $shang [ $i ]; //当前点击过来的条件 } $pos = intval ( strpos ( $topurl , $tiaojian )); //判断当前URL是否已经包含了条件 if ( $pos == "0" ) { $path = $topurl . $tiaojian ; } else { $path = str_replace ( $tiaojian , '' , $topurl ); } echo "<script>location.href='$path'</script>" ; ?> |