Seems a bit tedious really. Entering in so many keywords.
Here's a suggestion. Instead of entering in all those keywords, get it to parse your html files instead and auto-generate the keywords from that at runtime.
So, you have all of a particular file loaded into an array. Convert it all to 1 string, remove new line characters and carriage returns (maybe you can put it directly into a string, i'm not sure, i've never tried).
Make use of the explode() function to split up your string at every '<'.
By using the foreach function and a variable (set it to 1 every time the current array value is '<' and 0 when it's not), for every array element that's NOT '<' and the variable marker is set to 0, you add the current array element to a new array. (you'll need to add more marker variables too to also remove text that would be inside 'script and style tags and other things you don't want to be used for your search engine.
Now, convert that new array to a string, explode at '>', use foreach to add all elements EXCEPT '>' to a new array.
You would have it ignore most tags (starting with a < and ending with >, for image tags, get it enter the alt attribute and/or the title attribute into an array.
Get it to ignore everything inside a script, style or php tag, possibly also anchor tags. Go through your website's code to find anything else i might not have thought about that could cause problems.
Perhaps remove common terms like "The" "of" "and" etc... or anything you don't want to be considered.
For the most part, you now have a list of all search keywords from a particular html file stored in an array. Use whatever method you like to go though that array and match up the words to your search terms. etc etc... you get the idea.
If any of that's too confusing, let me know and i'll try to explain.
Yes, i know this is a bit more complicated than just entering in keywords manually, but it's dynamic. The code can be re-used anywhere so it'll save you time in the long run.
*edit*, whoops, broke the forum with that spiel. Fixed now.
__________________
Subtlety is my middle name... and first and last in case you didn't get the point.
Last edited by LeadMagnet; 30-09-2007 at 04:20 PM.
|