欢迎来到素材无忧网,按 + 收藏我们
登录 注册 退出 找回密码

dede地区联动搜索 彻底解决办法

时间: 2018-12-11 08:44 阅读: 作者:素材无忧网

本例以文章模型为列子
0 添加 联动类型 地区

plus/search.php
<?php
require_once(dirname(__FILE__)."/../include/common.inc.php");
require_once(DEDEINC."/arc.searchview.class.php");

$pagesize = (isset($pagesize) && is_numeric($pagesize)) ? $pagesize : 10;
$typeid = (isset($typeid) && is_numeric($typeid)) ? $typeid : 0;
$nativeplace = (isset($nativeplace) && is_numeric($nativeplace)) ? $nativeplace : 0;
$channeltype = (isset($channeltype) && is_numeric($channeltype)) ? $channeltype : 0;
$kwtype = (isset($kwtype) && is_numeric($kwtype)) ? $kwtype : 1;
$mid = (isset($mid) && is_numeric($mid)) ? $mid : 0;

if(!isset($orderby)) $orderby=”;
else $orderby = eregi_replace(‘[^a-z]‘,”,$orderby);

if(!isset($searchtype)) $searchtype = ‘titlekeyword’;
else $searchtype = eregi_replace(‘[^a-z]‘,”,$searchtype);

if(!isset($keyword)) $keyword = ”;

$oldkeyword = $keyword;

$keyword = FilterSearch(stripslashes($keyword));

//查找栏目信息
if(empty($typeid))
{
    $typenameCacheFile = DEDEROOT.’/data/cache/typename.inc’;
    if(!file_exists($typenameCacheFile) || filemtime($typenameCacheFile) < time()-(3600*24) )
    {
        $fp = fopen(DEDEROOT.’/data/cache/typename.inc’, ‘w’);
        fwrite($fp, "<"."?php\r\n");
        $dsql->SetQuery("Select id,typename From `ym_arctype`");
        $dsql->Execute();
        while($row = $dsql->GetArray())
        {
            fwrite($fp, "\$typeArr[{$row['id']}] = ‘{$row['typename']}’;\r\n");
        }
        fwrite($fp, ‘?’.'>’);
        fclose($fp);
    }
    //引入栏目缓存并看关键字是否有相关栏目内容
    require_once($typenameCacheFile);
    if(isset($typeArr) && is_array($typeArr))
    {
        foreach($typeArr as $id=>$typename)
        {
            $keywordn = str_replace($typename, ‘ ‘, $keyword);
            if($keyword != $keywordn)
            {
                $keyword = $keywordn;
                $typeid = $id;
                break;
            }
        }
    }
}

$keyword = addslashes(cn_substr($keyword,30));

if($cfg_notallowstr !=” && eregi($cfg_notallowstr,$keyword))
{
    ShowMsg("你的搜索关键字中存在非法内容,被系统禁止!","-1");
    exit();
}

//if(($keyword==” || strlen($keyword)<0) && empty($typeid))
//{
//    ShowMsg(‘关键字不能小于2个字节!’,'-1′);
//    exit();
/

版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!

转载请注明: dede地区联动搜索 彻底解决办法

标签:  
相关文章
模板推荐