本例以文章模型為列子
	0 添加 聯(lián)動類型 地區(qū)
	1 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);
	    }
	    //引入欄目緩存并看關(guān)鍵字是否有相關(guān)欄目內(nèi)容
	    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("你的搜索關(guān)鍵字中存在非法內(nèi)容,被系統(tǒng)禁止!","-1");
	    exit();
	}
	//if(($keyword==” || strlen($keyword)<0) && empty($typeid))
	//{
	//    ShowMsg(‘關(guān)鍵字不能小于2個字節(jié)!’,'-1′);
	//    exit();
	//}
	//檢查搜索間隔時間
	$lockfile = DEDEROOT.’/data/time.lock.inc’;
	if(!file_exists($lockfile)) {
	    $fp = fopen($lockfile,’w');
	    flock($fp,1);
	    fwrite($fp,time());
	    fclose($fp);
	}
	//開始時間
	if(empty($starttime)) $starttime = -1;
	else
	{
	    $starttime = (is_numeric($starttime) ? $starttime : -1);
	    if($starttime>0)
	    {
	       $dayst = GetMkTime("2008-1-2 0:0:0") – GetMkTime("2008-1-1 0:0:0");
	       $starttime = time() – ($starttime * $dayst);
	  }
	}
$t1 = ExecTime();
	$sp = new SearchView($typeid,$keyword,$orderby,$channeltype,$searchtype,$starttime,$pagesize,$kwtype,$mid,$nativeplace);
	$keyword = $oldkeyword;
	$sp->Display();
	//echo ExecTime() – $t1;
	?>
	2 templets/default/search.htm
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>{dede:global.cfg_webname/}_搜索結(jié)果</title>
	<link href="{dede:global.cfg_templeturl/}/style/search.css" rel="stylesheet" type="text/css" media="screen" />
	</head>
	<body>
	<div class="header">
	    <div class="toplogo">
	        <h1><a href="{dede:global.cfg_cmsurl/}/">{dede:global.cfg_webname/}</a></h1>
	    </div>
	    <div class="searchform">
	      <form action="{dede:field name=’phpurl’/}/search.php" name="formsearch">
	        <div class="s1">搜索</div>
	        <div class="s2">
	           <input type="hidden" name="kwtype" value="0" />
	           <input name="keyword" type="text" class="search-keyword" id="search-keyword" value="{dede:global.keyword/}" />
	<input type=’hidden’ id=’hidden_nativeplace’ name=’nativeplace’ value=’0′ />
	<span id=’span_nativeplace’></span>
	<span id=’span_nativeplace_son’></span>
	<script language="javascript" type="text/javascript" src="{dede:global.cfg_indexurl/}/images/enums.js"></script>
	<script language=’javascript’ type=’text/javascript’ src=’{dede:global.cfg_indexurl/}/data/enums/nativeplace.js’></script>
	<script language="javascript" type="text/javascript">MakeTopSelect("nativeplace", 0);</script>
	<input type=’hidden’ name=’dede_addonfields’ value="nativeplace,stepselect">
	           <select name="searchtype" class="search-option" id="search-option">
	               <option value="titlekeyword" selected=’1′>智能模糊搜索</option>
	               <option value="title">僅搜索標(biāo)題</option>
	           </select>
	          <button type="submit" class="search-submit">搜索</button>        
	        </div>
	        </form>
	        <div class="s3">
	            <a href="heightsearch.php">高級搜索</a>
	            <a href="{dede:global.cfg_cmsurl/}/">返回首頁</a>
	        </div>
	    </div>
	</div>
	<div class="msgbar">
	    <p>
	        搜索 <strong class="fc_03c">{dede:global name=’keyword’/}</strong> 的結(jié)果
	    </p>
	</div>
	<div class="resultlist">
	    
	{dede:list perpage=’20′}
	    <div class="item">
	        <h3><a href="[field:arcurl/]" target="_blank">[field:title/]</a></h3>
	        <p class="intro">[field:description/]…</p>
	        <p class="info">
	            <small> 分類:</small><span> <a href="[field:typeurl/]" target="_blank">[field:typename/]</a></span>
	            <small>點擊:</small><span> [field:click/]</span>
	            <small>日期:</small><span> [field:stime/]</span>
	        </p>
	        <p><span><a href="[field:arcurl/]" target="_blank">[field:arcurl/]</a></span></p>
	    </div>
	{/dede:list}
</div>
	<div class="dede_pages">
	    <ul class="pagelist">
	        {dede:pagelist listsize=’5′/}  
	    </ul>
	</div><!– /pages –>
	<div class="othersearch">
	    <h2>相關(guān)搜索:</h2>
	    <ul>
	        {dede:likewords num=’8′/}
	    </ul>
	</div>
	<div class="footer">
	    <p class="link">
	        網(wǎng)站版權(quán)信息及免責(zé)聲明
	    </p>
	    <!–
	        為了支持織夢團(tuán)隊的發(fā)展,請您保留織夢內(nèi)容管理系統(tǒng)的鏈接信息.
	        我們對支持織夢團(tuán)隊發(fā)展的朋友表示真心的感謝!織夢因您更精彩!
	    –>
	    <p class="powered">
	        Powered by <a href="http://www.dedecms.com" title="織夢內(nèi)容管理系統(tǒng)(DedeCms)–國內(nèi)最專業(yè)的PHP網(wǎng)站管理系統(tǒng),輕松建站的首選利器。" target="_blank"><strong>Dede<span>CMS</span></strong></a> ? 2004-2008 DesDev Inc.
	    </p><!– /powered –>
	    
	</div>
	</body>
	</html> 
新聞熱點
疑難解答
圖片精選