phpcms v9二次开发实现联动筛选菜单功能

发布时间:2019-07-24编辑:脚本学堂
phpcms v9二次开发实现联动筛选菜单功能

本案例是根据伪静态以及动态的进行筛选而写的。
效果如下:
img1
首先:我们在后台添加联动菜单
img2
第二步:我们要写一个伪静态规则,在网站根目录下新建一个.htaccess文件  
 

复制代码 代码如下:
Options +FollowSymLinks
# if you want to use mod_rewrite, set this 'On'
RewriteEngine On
RewriteCond %{HTTP_HOST} ^176cto.com [NC]
RewriteRule ^(.*)$ http://www.176cto.com/$1 [L,R=301]
RewriteRule ^(.*)slist/([0-9]+)/([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)$ $1/index.php?m=content&c=slist&a=init&catid=$2&fenge=$3&kongjian=$4&huxing=$5&beijing=$6&page=$7

最后一步在content模型下新建一个slist.php文件
 

复制代码 代码如下:
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
//模型缓存路径
define('CACHE_MODEL_PATH',CACHE_PATH.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);
pc_base::load_app_func('util','content');
class slist {
private $db;
function __construct() {
$this->db = pc_base::load_model('content_model');
}
public function init() {
include template('content','slist');
}
} ?>//其余参数自己写,我只是把模板导入进来而已

模板文件slits.html

复制代码 代码如下:
<div class="jiansuo">
<p><em>分类检索</em></p>
<dl><dt>风格:</dt>
<dd{if $_GET['fenge']==3475} class="on"{/if}><a href="{siteurl(1)}/slist/14 /3475-{$_GET['kongjian']}-{$_GET['huxing']}-{$_GET['beijing']}-1">全 部</a></dd>
{loop get_linkagelist(3475) $type}
<dd {if $_GET['fenge']==$type['linkageid']} class="on"{/if}><a href="{APP_PATH}slist/14/{$type['linkageid']}-{$_GET['kongjian']}-{$_GET['huxing']}-{$_GET['beijing']}-1">{$type['name']}</a></dd>
{/loop}
</dl>
<dl><dt>空间:</dt>
<dd{if $_GET['kongjian']==3482} class="on"{/if}><a href="{siteurl(1)}/slist/14 /{$_GET['fenge']}-3482-{$_GET['huxing']}-{$_GET['beijing']}-1">全部< /a></dd>
{loop get_linkagelist(3482) $type}
<dd {if $_GET['kongjian']==$type['linkageid']} class="on"{/if}><a href="{APP_PATH}slist/14/{$_GET['fenge']}-{$type['linkageid']}-{$_GET['huxing']}-{$_GET['beijing']}-1">{$type['name']}</a></dd>
{/loop}
</dl>
<dl><dt>户型:</dt>
<dd{if $_GET['huxing']==3489} class="on"{/if}><a href="{siteurl(1)}/slist/14 /{$_GET['fenge']}-{$_GET['kongjian']}-3489-{$_GET['beijing']}-1">全 部</a></dd>
{loop get_linkagelist(3489) $type}
<dd {if $_GET['huxing']==$type['linkageid']} class="on"{/if}><a href="{APP_PATH}slist/14/{$_GET['fenge']}-{$_GET['kongjian']}-{$type['linkageid']}-{$_GET['beijing']}-1">{$type['name']}</a></dd>
{/loop}
</dl>
<dl><dt>背景墙:</dt>
<dd{if $_GET['beijing']==3496} class="on"{/if}><a href="{siteurl(1)}/slist/14 /{$_GET['fenge']}-{$_GET['kongjian']}-{$_GET['huxing']}-3496-1">全 部</a></dd>
{loop get_linkagelist(3496) $type}
<dd {if $_GET['beijing']==$type['linkageid']} class="on"{/if}><a href="{APP_PATH}slist/14/{$_GET['fenge']}-{$_GET['kongjian']}-{$_GET['huxing']}-{$type['linkageid']}-1">{$type['name']}</a></dd>
{/loop}
</dl>
</div>