首页 > 代码库 > destoon手机端mobileurl函数增加城市分类参数
destoon手机端mobileurl函数增加城市分类参数
mobileurl函数在include/global.func.php 858行
共四个参数,moduleid-模型id,catid-分类id,itemid -文章id,page-页码
function mobileurl($moduleid, $catid = 0, $itemid = 0, $page = 1) { if(RE_WRITE) return $moduleid.‘-‘.$catid.‘-‘.$itemid.‘-‘.$page.‘.html‘; if($itemid) { return ‘index.php?moduleid=‘.$moduleid.‘&itemid=‘.$itemid.($page > 1 ? ‘&page=‘.$page : ‘‘); } else if($catid) { return ‘index.php?moduleid=‘.$moduleid.‘&catid=‘.$catid.($page > 1 ? ‘&page=‘.$page : ‘‘); } else { return ‘index.php?moduleid=‘.$moduleid.($page > 1 ? ‘&page=‘.$page : ‘‘); } }
1、mobileurl函数增加areaid参数
function mobileurl($moduleid, $catid = 0, $itemid = 0, $page = 1, $areaid=0) { //if(RE_WRITE) return $moduleid.‘-‘.$catid.‘-‘.$itemid.‘-‘.$page.‘.html‘; if(RE_WRITE) return $moduleid.‘-‘.$catid.‘-‘.$itemid.‘-‘.$page.‘-‘.$areaid.‘.html‘; //edit by dp 12-03 for $areaid if($itemid) { return ‘index.php?areaid=‘.$areaid.‘&moduleid=‘.$moduleid.‘&itemid=‘.$itemid.($page > 1 ? ‘&page=‘.$page : ‘‘); } else if($catid) { return ‘index.php?areaid=‘.$areaid.‘&moduleid=‘.$moduleid.‘&catid=‘.$catid.($page > 1 ? ‘&page=‘.$page : ‘‘); } else { return ‘index.php?areaid=‘.$areaid.‘&moduleid=‘.$moduleid.($page > 1 ? ‘&page=‘.$page : ‘‘); } }
2、修改伪静态规则 根目录web.config文件 增加
<rule name="destoon_rewrite_8"> <match url="^(.*)/([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\.html\?*(.*)$" /> <action type="Rewrite" url="{R:1}/index.php?moduleid={R:2}&catid={R:3}&itemid={R:4}&page={R:5}&areaid={R:6}" /> </rule>
3、修改手机页面模板 template/default/mobile/sell.htm
<div class="p-20 f-l ss-js"> <span class="sort-tt border-r-1 s-cate">按地区</span> <div class="pro-cat pro-cat-hide"> <div class="cat-l"> <div class="cat-l-box" id="scroller3"> {php $tags=tag("table=area&condition=parentid=0&pagesize=100&order=listorder asc&template=null");} <ul> {loop $tags $i $c} <li{if $i<1} class="li-active"{/if}>{if $c[child]}{$c[areaname]}{else}<a href="http://www.mamicode.com/{mobileurl(16, $catid,0,1,$c[areaid])}" data-ajax=‘false‘>{$c[areaname]}</a>{/if} </li> {/loop} </ul> </div> </div> <div class="cat-m"> <div class="cat-close"><a href="http://www.mamicode.com/javascrip:void(0)"></a></div> <div class="cat-r cat-r-box" id="scroller4"> {php $tags=tag("table=area&condition=parentid=0&pagesize=100&order=listorder asc&template=null");} <div> {loop $tags $i $b} {php $sub = get_mainarea($b[arrchildid]);} <div class="con-block{if $i>=1} zl-hide {/if}"> <ul style="padding-top:1em"> <li> <p> {loop $sub $j $v} <span><a href="http://www.mamicode.com/{mobileurl(16, $catid,0,1,$v[areaid])}" data-ajax=‘false‘ >{$v[areaname]}</a></span> {/loop} </p> </li> </ul> </div> {/loop} </div> </div> </div> </div> </div>
4、给按类别加上地区参数
<div class="p-20 f-l ss-js"> <span class="sort-tt border-r-1 s-cate">按类别</span> <div class="pro-cat pro-cat-hide"> <div class="cat-l"> <div class="cat-l-box" id="scroller"> {php $maincat = get_maincat(0, 16, 1);} <ul> {loop $maincat $i $c} <li{if $i<1} class="li-active"{/if}>{if $c[child]}{$c[catname]}{else}<a href="http://www.mamicode.com/{mobileurl(16, $c[catid],0,1,$areaid)}" data-ajax=‘false‘>{$c[catname]}</a>{/if} </li> {/loop} </ul> </div> </div> <div class="cat-m"> <div class="cat-close"><a href="http://www.mamicode.com/javascrip:void(0)"></a></div> <div class="cat-r cat-r-box" id="scroller2"> {php $child = get_maincat(0, 16, 1);} <div> {loop $child $i $c} <div class="con-block{if $i>=1} zl-hide {/if}"> <ul> {php $sub = get_maincat($c[catid], 16, 1);} {loop $sub $j $s} <li> <h1>{$s[catname]}</h1> {php $child = get_maincat($s[catid], 16, 1);} <p> {loop $child $r $e} <span><a href="http://www.mamicode.com/{mobileurl(16, $e[catid],0,1,$areaid)}" data-ajax=‘false‘ >{$e[catname]}</a></span> {/loop} </p> </li> {/loop} </ul> </div> {/loop} </div> </div> </div> </div> </div>
7 、对应 修改 template/default/mobile/group.htm
8、增加排序以后的mobileurl函数,伪静态规则
function mobileurl($moduleid, $catid = 0, $itemid = 0, $page = 1, $areaid=0, $order=0) { //if(RE_WRITE) return $moduleid.‘-‘.$catid.‘-‘.$itemid.‘-‘.$page.‘.html‘; if(RE_WRITE) return $moduleid.‘-‘.$catid.‘-‘.$itemid.‘-‘.$areaid.‘-‘.$order.‘-‘.$page.‘.html‘; //edit by dp 12-03 for $areaid if($itemid) { return ‘index.php?order=‘.$order.‘&areaid=‘.$areaid.‘&moduleid=‘.$moduleid.‘&itemid=‘.$itemid.($page > 1 ? ‘&page=‘.$page : ‘‘); } else if($catid) { return ‘index.php?order=‘.$order.‘&areaid=‘.$areaid.‘&moduleid=‘.$moduleid.‘&catid=‘.$catid.($page > 1 ? ‘&page=‘.$page : ‘‘); } else { return ‘index.php?order=‘.$order.‘&areaid=‘.$areaid.‘&moduleid=‘.$moduleid.($page > 1 ? ‘&page=‘.$page : ‘‘); } }
伪静态规则
<rule name="destoon_rewrite_8"> <match url="^(.*)/([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\.html\?*(.*)$" /> <action type="Rewrite" url="{R:1}/index.php?moduleid={R:2}&catid={R:3}&itemid={R:4}&page={R:7}&areaid={R:5}&order={R:6}" /> </rule>
9、模板链接
保留当前分类id 城市id 0-综合排序,1-按时间倒序,2-价格低到高,3-价格高到低,4-销量倒序
<div class="p-35 f-l sort-sel ss-js"> <span class="sort-tt border-r-1 redStyle s-one"><em class="sort-t">综合排序</em><i></i></span> <ul class="sort-ul"> <li><a href="http://www.mamicode.com/{mobileurl(16, $catid,0,1,$areaid,0)}" data-ajax=‘false‘ >综合排序</a></li> <li><a href="http://www.mamicode.com/{mobileurl(16, $catid,0,1,$areaid,1)}" data-ajax=‘false‘ >最新发布</a></li> <li><a href="http://www.mamicode.com/{mobileurl(16, $catid,0,1,$areaid,2)}" data-ajax=‘false‘ >价格由低到高</a></li> <li><a href="http://www.mamicode.com/{mobileurl(16, $catid,0,1,$areaid,3)}" data-ajax=‘false‘ >价格由高到低</a></li> </ul> </div> <div class="p-25 f-l ss-js"> <span class="sort-tt border-r-1 s-xl"><a href="http://www.mamicode.com/{mobileurl(16, $catid,0,1,$areaid,4)}" data-ajax=‘false‘ >销量优先</a></span> </div>
destoon手机端mobileurl函数增加城市分类参数
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。