poscms 常用函数 dr_search_url()
2024-11-23 18:44:02
<!--<a href="{dr_search_url($params,'order',NULL)}" class="on">今日推荐</a>--> <!--<a href="{dr_search_url($params,'order','inputtime_desc')}" class="">最新发布</a>--> <!--<a href="{dr_search_url($params,'order','hits_desc')}" class="">人气排行</a>-->
<div class="layout mt50"> <div class="case-select-type"> <div class="case-nav"> <div class="nav-pos"> <a href="/" title="返回首页">首 页<em>></em></a> <a href="#" title="案例图库">设计案例</a> </div> </div> <dl class="case-type-dl"> <dt>户型</dt> <dd> <a href="#" class="on">不 限</a> {loop $huxing_final $key $value} {if $key<13} <a href="{dr_search_url($params,'huxing',$value.0)}" class="">{$value.0}</a> {/if} {/loop} </dd> </dl> <dl class="case-type-dl"> <dt>风格</dt> <dd> <a href="{dr_search_url($params,'fengge',NULL)}" class="on">不 限</a> {loop $fengge_final $key $value} {if $key<13} <a href="{dr_search_url($params,'fengge',$value.0)}" class="">{$value.0}</a> {/if} {/loop} </dd> </dl> <dl class="case-type-dl"> <dt>局部</dt> <dd> <a href="#" class="on">不 限</a> {loop $jubu_final $key $value} {if $key<13} <a href="{dr_search_url($params,'jubu',$value.0)}" class="">{$value.0}</a> {/if} {/loop} </dd> </dl> <dl class="case-type-dl"> <dt>空间</dt> <dd> <a href="#" class="on">不 限</a> {loop $kongjian_final $key $value} {if $key<13} <a href="{dr_search_url($params,'kongjian',$value.0)}" class="">{$value.0}</a> {/if} {/loop} </dd> </dl> </div> </div
/** * 搜索url组合 * * @param array $params 搜索参数数组 * @param string $name 当前参数名称 * @param string $value 当前参数值 * @param string $urlrule 搜索url规则 * @param string $moddir 强制定位到模块 * @return string */ function dr_search_url($params = NULL, $name = NULL, $value = NULL, $urlrule = NULL, $moddir = NULL) { defined('MOD_DIR') && MOD_DIR && $dir = MOD_DIR; if (!is_array($params) && $params && is_dir(WEBPATH.$params)) { $dir = (string)$params; $params = array(); } else { $params = is_array($params) ? $params : array(); } $dir = $moddir ? $moddir : $dir; if ($name) { if (strlen($value)) { $params[$name] = $value; } else { unset($params[$name]); } } if (is_array($params)) { foreach ($params as $i => $t) { if (strlen($t) == 0) { unset($params[$i]); } } } $ci = &get_instance(); $mod = $ci->get_cache('module-'.SITE_ID.'-'.$dir); $rule = $ci->get_cache('urlrule', (int)$mod['site'][SITE_ID]['urlrule'], 'value'); if ($rule && $rule['search']) { $data['modname'] = $mod['dirname']; //$data['param'] = dr_rewrite_encode($params); $data['param'] = dr_rewrite_encode($params, $mod['setting']['search']['param_join'], $mod['setting']['search']['param_field']); $url = ltrim($params ? $rule['search_page'] : $rule['search'], '/'); // 兼容php5.5 if (version_compare(PHP_VERSION, '5.5.0') >= 0) { $rep = new php5replace($data); $url = preg_replace_callback("#{([a-z_0-9]+)}#Ui", array($rep, 'php55_replace_data'), $url); $url = preg_replace_callback('#{([a-z_0-9]+)\((.*)\)}#Ui', array($rep, 'php55_replace_function'), $url); unset($rep); } else { $url = preg_replace('#{([a-z_0-9]+)}#Uei', "\$data[\\1]", $url); $url = preg_replace('#{([a-z_0-9]+)\((.*)\)}#Uie', "\\1(dr_safe_replace('\\2'))", $url); } return dr_uri_prefix('rewrite', $mod, array(), SITE_FID).$url; } else { return dr_uri_prefix('php', $mod, array(), SITE_FID).trim('c=search&'.@http_build_query($params), '&'); } }