织梦联动筛选伪静态[单链接形式]

伪静态URL

网站用的是静态,筛选用的是伪静态,筛选的伪静态地址以字段和键值呈现,让筛选URL与静态保持一致。

如:

静态栏目页

http://www.dedehtml.com/juji/

静态栏目页分页

http://www.dedehtml.com/juji/list_1_2.html

伪静态筛选页

http://www.dedehtml.com/juji/list_1_area_0.html

伪静态筛选分页

http://www.dedehtml.com/juji/list_1_area_0_2.html

【警告】
操作之前先备份你的程序这2个文件。
/include/arc.listview.class.php
/include/extend.func.php

织梦联动筛选伪静态[单链接形式]+伪静态规则 打包下载

链接: https://pan.baidu.com/s/1649Ww8iRSO1nKv1hopsiWw 密码: acna

使用说明

Ps:如果你的网站已经做了筛选功能的,请对比一下我的文件来修改再使用。

1. 选择对应的编码,把文件夹文件全部覆盖到对应目录;

2. 后台-系统配置 添加变量
    变量名称:cfg_rewritea
    变量类型:布尔(Y/N)
    参数说明:筛选伪静态
    变量值:Y
    所属组:站点设置

3. .htaccess 为apache伪静态,放在网站根目录,用于筛选伪静态使用,iis和nginx用户自行转换。

4. 设置网站整站为静态,生成,浏览网站带筛选的栏目,看效果。

内容页输出所属筛选值+链接(支持动态/伪静态)

打开 /nclude/extend.func.php 在最下面加入

/**
 *  内容页输出所属筛选值+链接
 *
 * @access    public
 * @param     string  $id	文档id
 * @param     string  $fieldsnamef	单个筛选字段
 * @return    string
 */
function GetFilterUrl($id,$fieldsnamef)
{
	global $dsql,$cfg_cmspath,$cfg_rewritea;
	if (!isset($id) && !is_numeric($id))
	{
		return '';
	}
	else
	{
		$arcrow = $dsql->GetOne(" Select typeid,channel From `#@_archives` where id='$id' ");
		$channelid = $arcrow['channel'];
		$tid = $arcrow['typeid'];
		$typerow = $dsql->GetOne(" Select typedir From `#@_arctype` where id='$tid' ");
		$typedir = MfTypedir($typerow["typedir"]);
		
		$channelrow = $dsql->GetOne("SELECT addtable FROM #@_channeltype where id='$channelid'");
		$addtable = trim($channelrow['addtable']);

		$fieldrow = $dsql->GetOne("SELECT $fieldsnamef FROM `$addtable` WHERE aid=$id");
	}
	$plist = $_SERVER['HTTP_X_REWRITE_URL'] ? string_filter($_SERVER['HTTP_X_REWRITE_URL']) : string_filter($_SERVER['REQUEST_URI']);
	if($cfg_rewritea == 'Y')
	{
		$plist = stripos($plist, "makehtml_list_action.php") ? $cfg_cmspath.$typedir.'/' : $plist;
		$filterarr = string_filter(stripos($plist, ".html") ? str_replace(".html", "", $plist) : $cfg_cmspath.$typedir.'/');
	}
	else
	{
		$nofilter = (isset($_REQUEST['TotalResult']) ? "&TotalResult=".$_REQUEST['TotalResult'] : '').(isset($_REQUEST['PageNo']) ? "&PageNo=".$_REQUEST['PageNo'] : '');
		$filterarr = string_filter(stripos($plist, "list.php?tid=") ? str_replace($nofilter, '', $plist) : $GLOBALS['cfg_cmsurl']."/plus/list.php?tid=".$tid);
	}

	$cInfos = $dsql->GetOne(" Select * From  `#@_channeltype` where id='$channelid' ");
	$fieldset = $cInfos['fieldset'];
	$dtp = new DedeTagParse();
    $dtp->SetNameSpace('field','<','>');
    $dtp->LoadSource($fieldset);
    $result = '';
    if(is_array($dtp->CTags))
    {
		foreach($dtp->CTags as $tida=>$ctag)
        {
            $field_name = $ctag->GetName();
			$fieldsname = $fieldsnamef ? explode(",", $fieldsnamef) : explode(",", $field_name);
			if( in_array($field_name, $fieldsname))
			{
				if($cfg_rewritea == 'Y')
				{
					$href = "";
					$addonfields_items = explode(",",$ctag->GetAtt('default'));

					$i = array_search($fieldrow[$fieldsnamef],explode(",",$ctag->GetAtt('default')));
					$filterarr1 = explode("list_", $filterarr);
					$href = $filterarr1[0]."list_".$tid.'_'.$field_name.'_'.$i;

					$href .= ".html";
					$href = str_replace(array("_".$field_name.".",".","_".$_REQUEST['TotalResult']."_".$_REQUEST['PageNo']),array(".",".",""),$href);
					
					$result .= '<a href="'.$href.'">'.$addonfields_items[$i].'</a>';

				}
				else
				{
					$addonfields_items = explode(",",$ctag->GetAtt('default'));
					
					$i = array_search($fieldrow[$fieldsnamef],explode(",",$ctag->GetAtt('default')));
					
					$href = stripos($filterarr,$ctag->GetName().'=') ? str_replace("=".$fields_value,"=".urlencode($addonfields_items[$i]),$filterarr) : $filterarr.'&'.$ctag->GetName().'='.urlencode($addonfields_items[$i]);
					$href = str_replace("&TotalResult=".$_REQUEST['TotalResult']."&PageNo=".$_REQUEST['PageNo'], "", $href);
					
					$result .= '<a title="'.$addonfields_items[$i].'" href="'.$href.'">'.$addonfields_items[$i].'</a>';
				}
			}
        }
    }
	return $result;
}

内容页模板中调用标签

<small>区域:</small>{dede:field.id function=GetFilterUrl(@me,'area')/}
<small>地铁:</small>{dede:field.id function=GetFilterUrl(@me,'subway')/}

标红的地方是你的筛选字段名

首页/列表页调用标签

区域:[field:id function=function=GetFilterUrl(@me,'area')/]

地铁:[field:id function=function=GetFilterUrl(@me,'subway')/]

转载于:https://www.cnblogs.com/dedehtml/p/9913822.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值