Gossamer Forum
Home : Products : DBMan : Customization :

Searching records with HTML code

Quote Reply
Searching records with HTML code
I have a newly-discovered glitch in my database. The moderator of the database includes HTML codes to improve the look and feel of the database records.

However, he's discovered that a search result for "font" will return nearly half the database; every record that has a FONT code in it.

Is there a way to make the search query somehow ignore all FONT codes, but yet display the information with all the codes in it?

--Lee
Quote Reply
Re: Searching records with HTML code In reply to
It would be preferable not to include the HTML codes within the records. Unless each record needs to have different formatting, the formatting can be accomplished through having html formatting in the html.pl file instead of in the records.

I don't know how to prevent sub query from looking at the HTML codes in a search. You know more about sub query than I do! Smile


------------------
JPD






Quote Reply
Re: Searching records with HTML code In reply to
*laugh* Yes well I still know very little about that part of the code. Smile

Unfortunately, coloring is a big thing with our records. He'll make phrases like "internal use only" red, or bold list item headers, things like that. Unfortunately, there is no other way to do that without putting the codes in there.

If I could figure out how to squish all fields of a record into a single variable, then it would be a piece a cake; I'd solve my boolean problem along with this one! But it just ain't that easy........

--Lee
Quote Reply
Re: Searching records with HTML code In reply to
If I could figure out how to delete all html codes with one regular expression, I could probably do it, too. But I haven't been successful in that, either.


------------------
JPD






Quote Reply
Re: Searching records with HTML code In reply to
Here you go!

$string =~ s/<([^>]|\n)*>/ /g;
Quote Reply
Re: Searching records with HTML code In reply to
Okay. Smile

This might work.

After

@values = &split_decode($line);

add

Code:
foreach $value (@values) {
$value =~ s/<([^>]|\n)*>//g;
}

Since the searching is done on the @values array, if you strip the html out of the array first, there won't be any searching done. Right? Smile


------------------
JPD






Quote Reply
Re: Searching records with HTML code In reply to
Good idea, now how to we put the HTML codes back in for displaying? Wink
Quote Reply
Re: Searching records with HTML code In reply to
You want me to think of everything?!?!?! Wink

I hadn't thought about that. Smile

The only thing I can think of is to keep a mirror array -- one with the html codes and one without. Do the searching on the one without, but send the one with. How to accomplish that? I have no idea. But it might give you an idea. Smile


------------------
JPD






Quote Reply
Re: Searching records with HTML code In reply to
You know, I think I'm becoming obsessed with this. Today on our regular Saturday "go out for late brunch" I spent most of the time talking to my hubby about this problem. Smile

I think I got it.

Add the code I gave you earlier which takes out the HTML.

Then (oh, this is sneaky as all get-out!), after

Code:
if ($key_match &#0124; &#0124; (!($in{'keyword'}) && !($in{'ma'}))) {

add

Code:
@values = &split_decode($line);

The $line variable still has the original HTML coding in it. You search on the stripped array, then, if there's a match, you replace it with the original array. Smile

The only thing you lose in time is that the array is "split_decoded" twice -- but only if there's already a match. I think this is the best we can do.

------------------
JPD






Quote Reply
Re: Searching records with HTML code In reply to
JPD,

Thanks for all your help. Smile I just got back from a quick weekend vacation on the beach, so I'll try this code out tomorrow when I get back into the office. I'll be sure to let you know how it works. Smile

I also have another "html in the code" problem, but I'll make sure this works first, then start another post. To give you an idea, I have the AutoURL 2.0 MOD installed. I've had to disable keyword bolding, because it would mess up the URL's. Wink But like I said. I'll make this another thread.
--Lee
Quote Reply
Re: Searching records with HTML code In reply to
Brilliant work, JPD. It worked like a charm! Now, onto my other problem....... (new thread)

--Lee
Quote Reply
Re: Searching records with HTML code In reply to
Cool! Smile

It must have been the ham and cheese omelet I had for brunch that day. Smile


------------------
JPD