模板标签里面
求价格区间自定义的筛选代码,价格从【 】到【 】这样的代码。
<div class="item">
<div class="column">价格区间:</div>
<div class="list">
<ul>
{php $price=array('0,60'=>'0-60元','61,150'=>'61-150元','151,300'=>'151-300元','301,30000'=>'301-300000元');}
<li><a class="label {if !$params.price}on{else}default{/if}" href="{Router::search_url($params, 'price', NULL)}">不限</a></li>
{loop $price $i $t}
<li><a class=" {if $i==$params.price}on{else}default{/if}" href="{Router::search_url($params, 'price', $i)}">{$t}</a></li>
{/loop}
</ul>
</div>
<div class="form">
<span class="input"><input type="" name="" value="{$price[0]}" id="price_min" /></span>
<em>-</em>
<span class="input"><input type="" name="" value="{$price[1]}" id="price_max" /></span>
<span class="button"><button type="button">确定</button></span>
</div>
</div>
URL地址相对路径:
模板文件相对路径:search.html
function mmmmm() { var url="{Router::search_url($params, 'price', 'pppp')}"; // 这是按价格范围的写法参数替换 var price_min = $("#price_min").val(); var price_max = $("#price_max").val(); price_max = price_max ? price_max : 0; price_min = price_min ? price_min : 0; if (price_max || price_min) { url = url.replace('pppp', price_min+','+price_max); } else { url = url.replace('pppp', ''); } }😛 用默认模板的js改造下就可以了啊,换一个字段名字而已