Results Page

G

Guest

I have inserted a call to an asp page to do a site search

Here is the code that I can put on any page to do a search

<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Search term or phrase</title></head><table border=0 cellpadding=5 bgcolor=#AAAAAA><form method="POST" action="search.asp"><tr><td>Search term or phrase &nbsp; <input type=text name=term size=15>&nbsp; <input type=submi
value="search"></td></tr></form></table><body></body></html

That works great and then I have the results page

<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Search term or phrase</title></head><body><%
DIM Listoffilesfound,Thefile,Thefolder,Folderpat

if request.form="" the
SendForm(
els

SearchTerm = Server.HTMLencode(request.form("term")
SearchTermArray=Split(SearchTerm," "
MaxSearchTerms=ubound(SearchTermArray

Filestosearch="/index.htm,/bio.htm,/issues.htm,/newsletter.htm,/photogallery.htm

DonotsearchthisFiles ="

Folderpath=server.mappath("\"
' Search file
FilestosearchArray=Split(Filestosearch,","
Maxfiles=ubound(FilestosearchArray
for i=0 to Maxfile
Thefile = FilestosearchArray(i
Searchit(
nex

' Write search result
Searchresponse(


end i
%><% Sub SendForm() %><HTML><HEAD><TITLE>Search</TITLE></HEAD><BODY BGCOLOR=FFFFFF><CENTER><form method="POST" action="search.asp"><table border=0 cellpadding=5 bgcolor=AAAAAA><tr><td align=center>
Search term or phrase &nbsp; <input type=text name=term size=15>&nbsp; <input type=submi
value="search"></td></tr></table></form></CENTER></BODY></HTML><% End Sub %><% Sub Searchresponse() %><HTML><HEAD><TITLE>Search results</TITLE></HEAD><BODY BGCOLOR=FFFFFF><CENTER><TABLE BORDER=0 WIDTH=600><TR><TD BGCOLOR=#9999FF><p align="center"><FONT SIZE=5 face="Trebuchet MS" color="#FFFFFF"><B>Search Results</B></FONT></TD></TR></TABLE><TABLE BORDER=0 WIDTH=600><% if Listoffilesfound="" then %><TR><TD>The specified term or phrase was not found</TD></TR><% else
Response.Write (Listoffilesfound)
end if %></TABLE><TABLE BORDER=0 WIDTH=600><TR><TD BGCOLOR=#9999FF ALIGN=RIGHT>&nbsp;</TD></TR></TABLE></CENTER></BODY></HTML><% End Sub %><% Sub Searchit()
Thefilepath=Folderpath & Thefil
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile(Thefilepath)
ThecontentofFile = a.ReadAll
a.close

Findterms=
for j=0 to MaxSearchTerm
if instr(1,ThecontentofFile,SearchTermArray(j),1)>0 then
Findterms=Findterms+
end i
nex

if Findterms=MaxSearchTerms+1 then

if instr(1,ThecontentofFile,"</title>",1)>0 and instr(1,ThecontentofFile,"<title>",1)>0 then
TheTitle=left(ThecontentofFile,instr(1,ThecontentofFile,"</title>",1)-1)
TheTitle=right(TheTitle,len(TheTitle)-instr(1,TheTitle,"<title>",1)-6)
els
TheTitle="No Title
end if

Listoffilesfound= Listoffilesfound & "<TR><TD>" & TheTitle & "</TD><TD ALIGN=CENTER VALIGN=MIDDLE><A HREF=" & Thefile & "> More </A></TD></TR>"

end i

End Sub %></body></html

the urls that they attach to are www.votekahn.com/searchtest.asp which has the search box an
www.votekahn.com/search.asp which displays the result

My question is, is there any way that I can customize the results page that pops up to display more information. Like a couple of sentences with the keyword in it, or the date last updated, so on and so forth

If you look at it know the search.asp page comes up with just page names, and nothing about the search word entered

Thanks for any help in advance
M. Anderson
 
J

Jim Buyens

Where you have:
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile(Thefilepath)
you could insert teh 2nd line shown below:
Set fs = CreateObject("Scripting.FileSystemObject")
Set fileinfo = fso.GetFile(Thefilepath)
Set a = fs.OpenTextFile(Thefilepath)
Then fileinfo.DateLastModified would return the file's
last modified date.

Showing file segments including the search terms would be
more difficult. Where you have:

if instr(1,ThecontentofFile,SearchTermArray(j),1)>0 then
Findterms=Findterms+1
end if

You could change this to

begpos = instr(1,ThecontentofFile,SearchTermArray(j),1)
if begpos > 0 then
Findterms=Findterms+1
textfrag = mid(ThecontentofFile, _
pos - 20, _
len(SearchTermArray(j)) + 40)
end if

would give you the found term plus whatever occupies 20
bytes on either side. But it would be up to you to get
this into the results table.

BTW, take care not to display textfrag directly. Instead,
display server.htmlencode(textfrag). If you display
textfrag only, it may contain HTML tags that interfere
with the rest of the page.

I must tell you, this is a terrible way to do full text
searching. You should really investigate the Web Search
feature built into FrontPage, or Microsoft Indexing
Service.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------




-----Original Message-----
I have inserted a call to an asp page to do a site search.

Here is the code that I can put on any page to do a search.

<html><head><meta http-equiv="Content-Type"
content="text/html; charset=windows-1252"><title>Search
term or phrase</title></head><table border=0
cellpadding=5 bgcolor=#AAAAAA><form method="POST"
action="search.asp"> said:
value="search"></td></tr></form></table><body></body></ht ml>

That works great and then I have the results page.

<html><head><meta http-equiv="Content-Type"
content="text/html; charset=windows-1252"> said:
DIM Listoffilesfound,Thefile,Thefolder,Folderpath

if request.form="" then
SendForm()
else

SearchTerm = Server.HTMLencode(request.form("term"))
SearchTermArray=Split(SearchTerm," ")
MaxSearchTerms=ubound(SearchTermArray)

Filestosearch="/index.htm,/bio.htm,/issues.htm,/newslette r.htm,/photogallery.htm"


DonotsearchthisFiles =""


Folderpath=server.mappath("\")
' Search files
FilestosearchArray=Split(Filestosearch,",")
Maxfiles=ubound(FilestosearchArray)
for i=0 to Maxfiles
Thefile = FilestosearchArray(i)
Searchit()
next


' Write search results
Searchresponse()




end if
%><% Sub SendForm() %
<HTML><HEAD><TITLE>Search</TITLE></HEAD><BODY
BGCOLOR=FFFFFF><CENTER><form method="POST"
action="search.asp"><table border=0 cellpadding=5
bgcolor=AAAAAA> said:
Search term or phrase <input type=text name=term size=15> <input type=submit
value="search"> said:
<HTML><HEAD><TITLE>Search results</TITLE></HEAD><BODY
BGCOLOR=FFFFFF><CENTER><TABLE BORDER=0 WIDTH=600><TR><TD
BGCOLOR=#9999FF><p align="center"><FONT SIZE=5
face="Trebuchet MS" color="#FFFFFF"><B>Search
Results</B></FONT></TD></TR></TABLE><TABLE BORDER=0
WIDTH=600> said:
Response.Write (Listoffilesfound)
end if %></TABLE><TABLE BORDER=0 WIDTH=600><TR><TD
BGCOLOR=#9999FF
ALIGN=RIGHT> said:
Thefilepath=Folderpath & Thefile
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile(Thefilepath)
ThecontentofFile = a.ReadAll
a.close

Findterms=0
for j=0 to MaxSearchTerms
if instr(1,ThecontentofFile,SearchTermArray(j),1)>0 then
Findterms=Findterms+1
end if
next

if Findterms=MaxSearchTerms+1 then

if instr(1,ThecontentofFile,"</title>",1)>0 and instr
(1 said:
TheTitle=left(ThecontentofFile,instr
(1 said:
TheTitle=right(TheTitle,len(TheTitle)-instr
(1 said:
else
TheTitle="No Title"
end if

Listoffilesfound= Listoffilesfound & "<TR><TD>" &
TheTitle & said:
end if

End Sub %></body></html>

the urls that they attach to are
www.votekahn.com/searchtest.asp which has the search box
andwww.votekahn.com/search.asp which displays the results
My question is, is there any way that I can customize
the results page that pops up to display more
information. Like a couple of sentences with the keyword
in it, or the date last updated, so on and so forth.
If you look at it know the search.asp page comes up with
just page names, and nothing about the search word
entered.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top