织梦联动筛选伪静态[单链接形式]
发布时间:2021-04-30 | 发布者: | 浏览次数: 次伪静态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
织梦联动筛选伪静态[单链接形式] 伪静态规则 打包下载
使用说明
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 getfilter
{
global $dsql,$cfg_cmspath,$cfg_rewritea;
if (!isset($id) && !is_numeric($id))
{
return '';
}
else
{
$arcrow = $dsql->getone(" select typeid,channel from `dede_archives` where id='$id' ");
$channelid = $arcrow['channel'];
$tid = $arcrow['typeid'];
$typerow = $dsql->getone(" select typedir from `dede_arctype` where id='$tid' ");
$typedir = mftypedir($typerow["typedir"]);
$channelrow = $dsql->getone("select addtable from dede_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 `dede_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 .= '';
}
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 .= '';
}
}
}
}
return $result;
}
内容页模板中调用标签
区域:{dede:field.id function=getfilter/}
地铁:{dede:field.id function=getfilter/}
标红的地方是你的筛选字段名
下载app送体验金26元首页/列表页调用标签
区域:[field:id function=function=getfilter/]
地铁:[field:id function=function=getfilter/]
iis7 伪静态规则
转载请标注:——