准备:PJBlog2 下载插件 1.0
演示:http://www.mebox.cn/LoadMod.asp?plugins=downloadForPJBlog
说明:给下载插件添加搜索功能
操作:
1、搜索代码
首先用任意一款文本编辑器打开download.asp(X:\pjblog2\Plugins\download),找到代码(32行左右)[code]if Request.QueryString(“action”)=”1″ then
SQL=”Select * FROM blog_Download where downl_Cate=1 orDER BY downl_PostTime desc”
elseif Request.QueryString(“action”)=”2″ then
SQL=”Select * FROM blog_Download where downl_Cate=2 orDER BY downl_PostTime desc”
elseif Request.QueryString(“action”)=”3″ then
SQL=”Select * FROM blog_Download where downl_Cate=3 orDER BY downl_PostTime desc”
elseif Request.QueryString(“action”)=”4″ then
SQL=”Select * FROM blog_Download where downl_Cate=4 orDER BY downl_PostTime desc”
elseif Request.QueryString(“action”)=”5″ then
SQL=”Select * FROM blog_Download where downl_Cate=5 orDER BY downl_PostTime desc”
else
SQL=”Select * FROM blog_Download orDER BY downl_PostTime desc”
end if
[/code]
用以下代码替换上面找到的代码[code]’优化代码并增加搜索功能 By:vjlin 2006-9-15 始
Dim iID,sSearch,sKey,sSQLWhere
sSearch = Int(Request(“search”))
sKey = CheckStr(Request(“key”))
iID = Int(Request.QueryString(“action”))
If sSearch = 1 Then sSQLWhere = ” AND downl_Name LIKE ‘%”&sKey&”%'”
If iID > 0 AND iID < 6 Then SQL="Select * FROM blog_Download where downl_Cate="&iID&sSQLWhere&" orDER BY downl_PostTime desc" Else SQL="Select * FROM blog_Download Where downl_ID=downl_ID"&sSQLWhere&" orDER BY downl_PostTime desc" End If '优化代码并增加搜索功能 By:vjlin 2006-9-15 末 [/code] 2、搜索表单 找到代码[code]<%=item5%>
[/code]
在这后面增加以下代码(注意有两处)[code]
[/code]
3、搜索参数
找到代码MultiPages=downPage(Log_Num,webLog.PageSize,CurPage,"&")
把它替换成MultiPages=downPage(Log_Num,webLog.PageSize,CurPage,"&search="&sSearch&"&key="&sKey&"&")
修改完成将文件上传就可以使用搜索功能了。
点击下载修改后的download.asp文件