ASPCMS 多条件查询

1. 表单样例:

                <form name="topFrm"  id="topFrm" action="/search.asp">
                    <input name="searchType" type="hidden" value="3" id="searchType" />
                    <input name="keys" type="hidden" value="all" id="keys" />
                    <div class="search-li">
                        <input name="Title" type="text" class="search-input" id="Title" />
                        <span>项目名称:</span></div>
                    <div class="search-li">
                        <input class="search-input" name="P_Area" type="text" id="P_Area" />
                        <span>区域:</span></div>
                    <div class="search-li">
                        <input class="search-input" name="P_Room" type="text" id="P_Room" />
                        <span>房型:</span></div>
                    <div class="search-li">
                        <input class="search-input" name="P_Cost" type="text" id="P_Cost" />
                        <span>造价:</span></div>
                    <div class="search-li">
                        <input class="search-input" name="P_DesignStyle" type="text" id="P_DesignStyle" />
                        <span>风格:</span></div>
                    <div class="search-btn"><a  href="javascript:topsearchSubmit();"><img src="{aspcms:sitepath}/Templates/{aspcms:defaulttemplate}/images/search_btn.gif" /></a></div>
                </form>
<script type="text/javascript">
    function topsearchSubmit()
    {
        topFrm.submit();
        return false;
    }
</script>

2. 修改"/inc/AspCms_MainClass.asp",修改查询语句(在源码的1484行)

'ASPCMS Start
'                    dim typeStr: typeStr=""
'                    dim searchType
'                    searchType=filterPara(getForm("searchType","get"))
'                    if isnul(searchType) then searchType="0"
'                    if  not "0"=searchType  then typeStr=" and a.SortID in (select {prefix}Sort.sortid from {prefix}Sort where sortType="&searchType&") "     
'                    sql="select ContentID,a.SortID,a.GroupID,a.Exclusive,Title,Title2,TitleColor,IsOutLink,OutLink,Author,ContentSource,ContentTag,Content,ContentStatus,IsTop,Isrecommend,IsImageNews,IsHeadline,IsFeatured,ContentOrder,IsGenerated,Visits,a.AddTime,a.[ImagePath],a.IndexImage,a.DownURL,a.PageFileName,a.PageDesc,SortType,SortURL,SortFolder,SortFileName,SortName,ContentFolder,ContentFileName,b.GroupID "&sperStr&" from {prefix}Content as a,{prefix}Sort as b where a.LanguageID="&setting.languageID&"and a.SortID=b.SortID and ContentStatus=1 and TimeStatus=0 and a.SortID in ("&getSubSort(typeIds, 1)&") and Title like '%"&keys&"%'"&typeStr&orderStr
'ASPCMS End

把上面修改成:

'Feva Start
Dim typeStr: typeStr=""
Dim searchType
searchType=filterPara(getForm("searchType","get"))
If isnul(searchType) Then searchType="0"
If Not "0"=searchType  Then typeStr=" and a.SortID in (select {prefix}Sort.sortid from {prefix}Sort where sortType="&searchType&") "     
If Not keys="all" Then 
    sql="select ContentID,a.SortID,a.GroupID,a.Exclusive,Title,Title2,TitleColor,IsOutLink,OutLink,Author,ContentSource,ContentTag,Content,ContentStatus,IsTop,Isrecommend,IsImageNews,IsHeadline,IsFeatured,ContentOrder,IsGenerated,Visits,a.AddTime,a.[ImagePath],a.IndexImage,a.DownURL,a.PageFileName,a.PageDesc,SortType,SortURL,SortFolder,SortFileName,SortName,ContentFolder,ContentFileName,b.GroupID "&sperStr&" from {prefix}Content as a,{prefix}Sort as b where a.LanguageID="&setting.languageID&"and a.SortID=b.SortID and ContentStatus=1 and TimeStatus=0 and a.SortID in ("&getSubSort(typeIds, 1)&") and Title like '%"&keys&"%'"&typeStr&orderStr
Else
    Dim formInput, keyValue, tempString : tempString = ""
    For Each formInput In Request.QueryString
        If Not formInput = "searchType" And Not formInput = "keys" And Not formInput = "page"  Then
            keyValue = filterPara(getForm(formInput, "get"))
            If Len(keyValue) > 0 And Len(filterPara(formInput)) > 0  Then
                tempString = tempString & " and " & formInput & " like '%" & keyValue & "%'"
            End If 
        End If
    Next
    tempString = tempString & " "
    sql="select ContentID,a.SortID,a.GroupID,a.Exclusive,Title,Title2,TitleColor,IsOutLink,OutLink,Author,ContentSource,ContentTag,Content,ContentStatus,IsTop,Isrecommend,IsImageNews,IsHeadline,IsFeatured,ContentOrder,IsGenerated,Visits,a.AddTime,a.[ImagePath],a.IndexImage,a.DownURL,a.PageFileName,a.PageDesc,SortType,SortURL,SortFolder,SortFileName,SortName,ContentFolder,ContentFileName,b.GroupID "&sperStr&" from {prefix}Content as a,{prefix}Sort as b where a.LanguageID="&setting.languageID&"and a.SortID=b.SortID and ContentStatus=1 and TimeStatus=0 and a.SortID in ("&getSubSort(typeIds, 1)&")"& tempString &typeStr&orderStr
End If
'Feva End

3. 修改"/inc/AspCms_CommonFun.asp",添加函数:

'Feva Start
'多条件分页使用
Function conditionSearch()
    Dim keys : keys =  filterPara(getForm("keys", "get"))
    If Not keys="all" Then 
'            strPageNumber=strPageNumber&"<a href=""?page="&pagenumber&"&keys="&keys&"&searchtype="&searchtype&""">"&pagenumber&"</a>"
            conditionSearch = ""
            Exit Function
    Else
        Dim formInput, keyValue, tempString : tempString = ""
        For Each formInput In Request.QueryString
            If Not formInput = "searchType" And Not formInput = "keys" And Not formInput = "page" Then
                keyValue = filterPara(getForm(formInput, "get"))
                If Len(keyValue) > 0 And Len(filterPara(formInput)) > 0 Then
                    tempString = tempString & "&" & formInput & "=" & keyValue
                End If 
            End If
        Next
        conditionSearch = tempString
        Exit Function
'        strPageNumber=strPageNumber&"<a href=""?page="&pagenumber&"&keys="&keys&"&searchType="&searchtype&tempString&""">"&pagenumber&"</a>"
    End If
End Function
'Feva End

3. 修改"/inc/AspCms_CommonFun.asp",分页中部函数 Function makePageNumber(Byval currentPage,Byval pageListLen,Byval totalPages,Byval linkType,Byval sortid, Byval showType) 修改:

'ASPCMS  Start
'                strPageNumber=strPageNumber&"<a href=""?page="&pagenumber&"&keys="&keys&"&searchtype="&searchtype&""">"&pagenumber&"</a>"
'ASPCMS  End

修改成:

'Feva Start
'注意searchType大小写问题
                strPageNumber=strPageNumber&"<a href=""?page="&pagenumber&"&keys="&keys&"&searchType="&searchtype& conditionSearch() &""">"&pagenumber&"</a>"
'Feva End

4. 修改"/inc/AspCms_CommonFun.asp",分页两侧函数 Function pageNumberLinkInfo(Byval currentPage,Byval pageListLen,Byval totalPages,Byval linkType,Byval sortid, Byval showType) 修改

'ASPCMS Start
'            firstPageLink="<a href='?page=1&keys="&keys&"&searchtype="&searchtype&"'>"&str_01&"</a>" : lastPagelink="<a href='?page="&currentPage-1&"&keys="&keys&"&searchtype="&searchtype&"'>"&str_03&"</a>"
'ASPCMS End

修改成:

'Feva Start
            firstPageLink="<a href='?page=1&keys="&keys&"&searchType="&searchtype&conditionSearch& "'>"&str_01&"</a>" : lastPagelink="<a href='?page="&currentPage-1&"&keys="&keys&"&searchType="&searchtype&conditionSearch&"'>"&str_03&"</a>"
'Feva End            

 

大功告成了,试过,没有错误 ASPCMS 2.5.4 beta 2  2014年7月28日

转载于:https://www.cnblogs.com/Weasel/p/4082204.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值