phpcmsv9如何设置分类phpcms筛选伪静态态

phpcms v9字段筛选教程
11:39:11&&&来源:www.abcde.cn&&&评论: 点击:
  第一步,添加筛选字段
  后台添加字段(类型选择多项 ,然后底下的选择下拉,单选,多选,都可以,根据自己的实际情况)、然后
  第一步,添加筛选字段
  后台添加字段(类型选择多项 ,然后底下的选择下拉,单选,多选,都可以,根据自己的实际情况)、然后选择作为筛选字段
  第二步,将extention.func.php覆盖到\phpcms\libs\functions这个目录下
  第三步,在你的list.html页面调用筛选字段,展现,代码如下
{loop&filters('方式',1)&$r}&
 {$r[menu]}&
 {/loop}&
  代码说明:
  参数fangshi 这个参数是你在后台添加的字段名 ,
  参数1 是模型id号
  Pc标签调用筛选后的结果代码:
{php&$sql&=&structure_filters_sql(1);}&
  {pc:content&action=&lists&&where=&$sql&&catid=&$catid&&modelid=&$modelid&&num=&10&&page=&$page&}&
  代码说明:参数1 是模型id号
原文标题:phpcms v9字段筛选教程
原文地址:
版权归网络时代所有,转载请注明出处
相关热词搜索:
延伸阅读:
频道总排行
频道本月排行提供主流cms教程
提供数据库教程和设计
提供各种常见网页js代码
提供常用的JS特效代码及在线演示
提供jQuery插件教程及插件下载
提供服务器常见问题及教程
提供站长技术、站长资讯等内容
提供常用开发手册和开发工具
您现在的位置:& >
phpcms v9把分类文件伪静态目录例子
目录伪静态在phpcmsv9中是不支持了,如果我们希望有这种效果是需要自行进行二次开发了,下面我们一起来看看具体的配置方法。
URL规则部分,使用phpcms的大多是知道的,就不再赘述。如果需要支持自定义文件名的,需要去看看phpcms v9自定义HTML文件名一文。下面就着重将Web服务器重写链接这一项。
phpcms v9怎么目录式伪静态:
首先看urlrewrite的规则,这个是Nginx下的,其它环境下的规则自己转换下。
rewrite&^/([a-z]+)/$&/index.php?m=content&c=index&a=lists&catdir=$1&&&&
rewrite&^/([a-z]+)/index_(\d+)\.html$&/index.php?m=content&c=index&a=lists&catdir=$1&page=$2&&&&
rewrite&^/([a-z]+)/([a-z0-9-]+)\.html$&/index.php?m=content&c=index&a=show&catdir=$1&prefix=$2&&&&
rewrite&^/([a-z]+)/([a-z0-9-]+)_(\d+)\.html$&/index.php?m=content&c=index&a=show&catdir=$1&prefix=$2&page=$3&&&&
这个Nginx规则就是把后面的链接重写为前面的链接形式的。所以接下来需要做的就是让后面的链接能够访问到正确的页面。phpcms v9默认是无法访问到正确页面的,因为缺少必要的参数。下面就对phpcms v9进行修改。
1、打开phpcms\modules\content目录下的index.php找到 public function lists() {,将$catid = intval($_GET['catid']);替换成:
if(isset&($_GET['catid'])){&&&
&&&$catid&=&intval($_GET['catid']);&&&
&&&$catid=$this-_getCategoryId($_GET['catdir']);&&&
//并且在最后的}&前添加:&&&
private&function&_getCategoryId($catdir){&&&
&&&&if(!strpos($catdir,'/'))&{&&&
&&&&&&&&$dirname&=&$&&&
&&&&}else&{&&&
&&&&&&&&$dirname&=&end(explode('/',$catdir));&&&
&&&&}//xiariboke.com&&&
&&&&&&&&$this-category_db&=&pc_base::load_model('category_model');&&&
&&&&&&&&$result&=&$this-category_db-get_one(array('catdir'=$dirname));&&&
&&&&return&$result['catid'];&&&
这段代码的作用就是判断参数是否catdir,栏目自定义目录名,如果是目录名则根据目录名得到对应的catid,从而顺利得到栏目页。理解了自定义目录的伪静态方法之后,自定义文件名的伪静态也就可以类似解决。
2、打开phpcms\modules\content目录下的index.php找到 public function show() {,
$catid&=&intval($_GET['catid']);&&&
$id&=&intval($_GET['id']);&&&
//替换成:&&&
if(isset&($_GET['catid'])){&&&
&&&&$catid&=&intval($_GET['catid']);&&&
&&&&$catid=$this-_getCategoryId($_GET['catdir']);&&&
if(isset($_GET['id'])){&&&
&&&&$id&=&intval($_GET['id']);&&&
&&&&$id&=&$this-_getPrefixId($_GET['catdir'],$_GET['prefix']);&&&
跟上面一样,还需要加上判断出文章id的函数,函数如下:
private&function&_getPrefixId($catdir,$prefix){&&&
&&&&if(!strpos($catdir,'/'))&{&&&
&&&&&&&&$dirname&=&$catdir;&&&
&&&&}else&{&&&
&&&&&&&&$dirname&=&end(explode('/',$catdir));&&&
&&&&$this-&category_db&=&pc_base::load_model('category_model');&&&
&&&&$result&=&$this-&category_db-&get_one(array('catdir'=&$dirname));&&&
&&&&$catid&=&$result['catid'];&&&
&&&&$siteids&=&getcache('category_content','commons');&&&
&&&&$siteid&=&$siteids[$catid];&&&
&&&&$CATEGORYS&=&getcache('category_content_'.$siteid,'commons');&&&
&&&&if(!isset($CATEGORYS[$catid])&||&$CATEGORYS[$catid]['type']!=0)&showmessage(L('information_does_not_exist'),'blank');&&&
&&&&$this-&category&=&$CAT&=&$CATEGORYS[$catid];&&&
&&&&$this-&category_setting&=&$CAT['setting']&=&string2array($this-&category['setting']);&&&
&&&&$siteid&=&$GLOBALS['siteid']&=&$CAT['siteid'];&&&
&&&&$MODEL&=&getcache('model','commons');&&&
&&&&$modelid&=&$CAT['modelid'];&&&
&&&&$tablename&=&$this-&db-&table_name&=&$this-&db-&db_tablepre.$MODEL[$modelid]['tablename'];&&&
&&&&$result&=&$this-&db-&get_one(array('prefix'=&$prefix));&&&
&&&&if(emptyempty($result)){&&&
&&&&&&&&$result&=&$this-&db-&get_one(array('id'=&$prefix));&&&
&&&&return&$result['id'];&&&
到这里之后,就可以通过自定义目录加自定义文件名的形式访问了。其他一些细节的地方,就不再赘述.1、打开phpcms\modules\content目录下的index.php找到 public function lists() {,将$catid = intval($_GET['catid']);
替换成如下代码:
if(isset ($_GET['catid'])){
$catid = intval($_GET['catid']);
$catdir=$_GET['catdir'];
if($catdir==&&){
$catdir=$_GET['categorydir'];
$s=$this-&_getCategoryId($catdir);
$catid=$s[0][catid];
并且在最后的}?& 前添加:
*根据栏目名获得ID
function _getCategoryId($catdir){
$this-&category_db = pc_base::load_model('category_model');
$result = $this-&category_db-&select(array('catdir'=&$catdir));
// print_r($result);
2、打开phpcms\modules\content\classes目录中的url.class.php,找到
if (!$setting['ishtml']) { //如果不生成静态
将下面的:
$url = str_replace(array('{$catid}', '{$page}'), array($catid, $page), $urlrule);
if (strpos($urls, '\\')!==false) {
$url = APP_PATH.str_replace('\\', '/', $urls);
$domain_dir = '';
if (strpos($category['url'], '://')!==false && strpos($category['url'], '?')===false) {
if (preg_match('/^((http|https):\/\/)?([^\/]+)/i', $category['url'], $matches)) {
$match_url = $matches[0];
$url = $match_url.'/';
$db = pc_base::load_model('category_model');
$r = $db-&get_one(array('url'=&$url), '`catid`');
if($r) $domain_dir = $this-&get_categorydir($r['catid']).
$this-&categorys[$r['catid']]['catdir'].'/';
$categorydir = $this-&get_categorydir($catid);
$catdir = $category['catdir'];
$year = date('Y',$time);
$month = date('m',$time);
$day = date('d',$time);
$urls = str_replace(array('{$categorydir}','{$catdir}','
{$year}','{$month}','{$day}','{$catid}','{$id}','{$prefix}','{$page}'),array
($categorydir,$catdir,$year,$month,$day,$catid,$id,$prefix,$page),$urlrule);
// echo $urls.&
if (strpos($urls, '\\')!==false) {
$urls = APP_PATH.str_replace('\\', '/', $urls);
$url = $domain_dir.$
3、后台URL规则中添加:
url示例:1/&&
url规则:{$categorydir}{$catdir}/|{$categorydir}{$catdir}/{$page}/
保存后更新栏目缓存就可以。
文章关键词:
热门PHPCMS教程
推荐PHPCMS教程phpcms分类筛选
[问题点数:20分,无满意结帖,结帖人u]
phpcms分类筛选
[问题点数:20分,无满意结帖,结帖人u]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
匿名用户不能发表回复!|如果大家不想复制代码,也可以直接下载下面的文件覆盖即可,下载地址如下:
说明一下,这里用的是模型里的下拉框,模板里面的调用代码如下:
&span&性别:&/span&
{php $xingbie_rang = array('男|1','女|2','组合|3')}
{loop filters('xingbie',$modelid,$xingbie_rang) $r}
{$r[menu]}
{php $sql = structure_filters_sql($modelid)}
{php $urlrule = makeurlrule()}
{pc:content action=&lists& catid=&$catid& where=&$sql& num=&35& order=&id DESC& page=&$page& moreinfo=&1& urlrule=&$urlrule&}
{loop $data $r}
&dt&&a href=&{$r[url]}& title=&{$r[title]}& target=&_blank&&&img src=&{$r[thumb]}& alt=&{$r[title]}& width=&130& height=&200& /&&/a&&/dt&
&dd&&h2&&a href=&{$r[url]}& title=&{$r[title]}& target=&_blank&&{$r[title]}&/a&&/h2&&/dd&
上面的代码是以性别为例的,大家可以自己修改。
如果要实现伪静态,可以参考下面的伪静态规则:
rewrite ^/list-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=lists&catid=$1&page=$2;
rewrite ^/list-([0-9]+)-(.*)-(.*)-(.*)-(.*)-([0-9]+).html /index.php?m=content&c=index&a=lists&catid=$1&diqu=$2&xingbie=$3&xingzuo=$4&zimu=$5&page=$6;
文章关键词:
热门PHPCMS教程
推荐PHPCMS教程

我要回帖

更多关于 phpcmsv9筛选功能插件 的文章

 

随机推荐