首页 > 代码库 > 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}&amp;catid={R:3}&amp;itemid={R:4}&amp;page={R:5}&amp;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&#123;if $i<1&#125; class="li-active"&#123;/if&#125;>&#123;if $c[child]&#125;&#123;&#36;c[areaname]&#125;&#123;else&#125;<a href="http://www.mamicode.com/{mobileurl(16, $catid,0,1,$c[areaid])}" data-ajax=‘false‘>&#123;&#36;c[areaname]&#125;</a>&#123;/if&#125;

            </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&#123;if $i>=1&#125; zl-hide &#123;/if&#125;">

              <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‘ >&#123;&#36;v[areaname]&#125;</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&#123;if $i<1&#125; class="li-active"&#123;/if&#125;>&#123;if $c[child]&#125;&#123;&#36;c[catname]&#125;&#123;else&#125;<a href="http://www.mamicode.com/{mobileurl(16, $c[catid],0,1,$areaid)}" data-ajax=‘false‘>&#123;&#36;c[catname]&#125;</a>&#123;/if&#125;

            </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&#123;if $i>=1&#125; zl-hide &#123;/if&#125;">

              <ul>

                {php $sub = get_maincat($c[catid], 16, 1);}

                {loop $sub $j $s}

                <li>

                  <h1>&#123;&#36;s[catname]&#125;</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‘ >&#123;&#36;e[catname]&#125;</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 : ‘‘);

}

}
View Code

 

伪静态规则

技术分享
<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}&amp;catid={R:3}&amp;itemid={R:4}&amp;page={R:7}&amp;areaid={R:5}&amp;order={R:6}"  />

 </rule>
View Code

 

 

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>
View Code

 

destoon手机端mobileurl函数增加城市分类参数