搜索

<span class="search_box">
     搜索:<input name="search" class="search_text" type="text" id="keyword" onkeydown="if (event.keyCode==13){SiteSearch('/search.html','keyword','products');}" />
          <input class="searchBtn" type="button" onclick="SiteSearch('/search.html', 'keyword', 'products')" />
</span>  

<script type="text/javascript">
function SiteSearch(send_url, divTgs, channel_name) {
var strwhere = "";
        if (channel_name !== undefined) {
            strwhere = "&channel=" + channel_name;
        }
        var str = document.getElementById(divTgs).value.trim();
        if (str.length > 0) {
            window.location.href = send_url + "?keyword=" + encodeURI(str) + strwhere;
        }
        return false;
    }
</script>
 

搜索结果显示页面search.html【案例:鹰洲科技】

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/templates/default/css/style.css" rel="stylesheet" />
    <script src="/templates/default/js/jquery-1.11.2.min.js"></script>
  
    <title>{site.seo_title}</title>
    <meta name="keywords" content="{site.seo_keywords}" />
    <meta name="description" content="{site.seo_description}" />
</head>
    <body>
        <%include file="_header.html"%>
                    
        <div class="wrapper clearfix">
            <%include file="_left.html"%>

            <div class="right">
                <%include file="_nav.html"%>
                <div class="clearfix"></div>
                <div class="right-bg">
                    <div class="container-buy">  
                        <div class="container-product-box">
                            <div class="container-product-list">                             
                                <h3 class="clearfix"><i>搜索关键词:{keyword}</i></h3>
                                <div class="clear"></div>
                                <div class="products-list">
                                    <%set DataTable searchList=get_search_list(pagesize, out totalcount)%>
                                    <%set string pagelist=get_page_link(pagesize, page, totalcount, linkurl("search","?keyword="+ keyword + "&amp;channel="+channel+"&amp;page=__id__"))%>
                                    <%if(totalcount>0)%>
                                    <ul class="clearfix">
                                        <%foreach(DataRow dr in searchList.Rows)%>
                                        <li><a href="<%linkurl("products_show",{dr[id]})%>"><img src="{dr[img_url]}"  alt="{dr[title]}"/><span>{dr[title]}</span></a></li><%/foreach%>
                                    </ul>   
                                </div>                
                                <div class="flickr">{pagelist}</div>
                                <div class="clear"></div> 
                                <%else%>
                                <p>很抱歉,找不到您要搜索的相关内容。</p>
                                <%/if%> 
                            </div>    
                            <div class="clear"></div>
                        </div>  
                    </div>
                </div>
            </div>
        </div>
        <%include file="_footer.html"%>
    </body>
</html>

 URL重写配置

<?xml version="1.0" encoding="utf-8"?>
<URLRewrite>
<rewrite name="search" type="other" page="search.aspx" inherit="Suctan.Web.UI.Page.search" templet="search.html" pagesize="10" />
</URLRewrite>

 

posted @ 2016-05-05 19:20  吖然-jronny  阅读(140)  评论(0编辑  收藏  举报