| Author |
Topic Search Topic Options
|
Gullanian
Senior Member
Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 July 2003 at 11:37am |
only thing is the snippet might start half way through a word, it would look better if you got x words before and after.
Yeah the thing I wrote should give you an idea of how to do it, but it is very buggy i didnt test it just wrote it in 5 mins
|
 |
usaboy
Newbie
Joined: 05 July 2003
Status: Offline
Points: 9
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 July 2003 at 12:10pm |
tanx ljamal... i did try to use that function but there were no result and i was getting the following error :
Technical Information (for support personnel)
- Error Type:
Microsoft VBScript runtime (0x800A01C2) Wrong number of arguments or invalid property assignment: 'inStrRev' /website4/SearchResults.asp, line 330
|
 |
ljamal
Mod Builder Group
Joined: 16 April 2003
Status: Offline
Points: 888
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 July 2003 at 12:42pm |
|
Change :
strString = left(strString, inStrRev(strString))
to
strString = left(strString, inStrRev(strString," "))
|
|
|
 |
usaboy
Newbie
Joined: 05 July 2003
Status: Offline
Points: 9
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 July 2003 at 1:41pm |
tanx ljamal... now i get the result page with no error.. but the problem is that there's nothing shown on the page.. just the ... trailing words before and after and the repeated region cols..
i guess somehow the whole string iss truncted!!! any idea/?
|
 |
ljamal
Mod Builder Group
Joined: 16 April 2003
Status: Offline
Points: 888
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 July 2003 at 3:26pm |
function FocusKeyword (strSting, strKeyword)
should be
function FocusKeyword (strSt ring, strKeyword)
I wrote this function when I read your post, so I didn't check it.
Here I even tested it for you this time so it does work. I found that 100 returned a string too long for my liking so I changed 100 to 50...
see it in action
|
|
|
 |
ljamal
Mod Builder Group
Joined: 16 April 2003
Status: Offline
Points: 888
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 July 2003 at 3:26pm |
|
Just posting the completed function:
function FocusKeyword (strString, strKeyword)
dim intPosition, intLength
intLength = 50
' get keyword's position in the string
intPosition = inStr(strString, strKeyword)
'truncate characters before keyowrd to intLength
if intPosition > intLength then
strString = Right(strString, len(strString)-intLength)
intPosition = inStr(strString, strKeyword)
end if
' truncate characters after the beginning of the keyword to intLength
if len(strString) > intPosition + intLength then
strString = Left(strString, intPosition+intLength)
end if
'truncate to the first space in the string
strString = right(strString, len(strString)-Instr(strString," "))
'truncate to the first space and the end of the string
strString = left(strString, inStrRev(strString," "))
'highlight keyword
strString = Replace(strString, strKeyword, "<b>"& strKeyword &"</b>")
'return string
FocusKeyword = strString
end function
|
|
|
 |
usaboy
Newbie
Joined: 05 July 2003
Status: Offline
Points: 9
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 July 2003 at 4:20pm |
tanx sooooo much ljamal... it did work for me too... but now the problem that i have is with multiple keywords search parameters... that this function works well with ONE keyword... but for more than ONE keyword it just shows few words... any idea what we can do about this???
once again i really appreciate your kind help and support.
|
 |
ljamal
Mod Builder Group
Joined: 16 April 2003
Status: Offline
Points: 888
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 July 2003 at 4:54pm |
|
The way the search engines deal with this is they find the first instance of any of the search terms (together or separate) and work from there. If there are other search terms near the first word, then they highlight all that appear.
I would use the split to separate the keywords into an array and determine which one appears first in the string. Then I would use that one to determine the length of the string and then highlight all the words in the array that appear in the new string. If I have time later, I'll work on it and post the function back to this thread.
|
|
|
 |