Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Highlight search results in html content


boxtel

Recommended Posts

Ignore my previous post. I see what's wrong now.

 

Your website, Boxtel, has advanced search 'incorporated' into the search box. Mine does not.

 

The highlighting IS occuring only when using the search box on the left side of my homepage.

 

But, when I go into Advanced Search, and select the box to search in product descriptions...there's no highlighting. How do I achieve THAT?

 

At present, the highlighting only occurs when searching thru product titles only. The keywords will be highlighted in the title AND the item description.

 

But...not when using Advanced Search to look for keywords WITHIN titles AND item descriptions.

 

Good Lord...I'm almost there!!!!!!!!

Link to comment
Share on other sites

  • Replies 62
  • Created
  • Last Reply

I'm mostly there but, 2 problems.

 

Searching within Advanced Search creates no highlight effect whatsoever.

 

Interesting problem with the Search Box itself.

 

If I surround keywords with quotation marks, it will bring up those items (searching thru titles only) but there is no highlight effect.

 

If I click on any of the items returned from that search, I get a screen full of this:

 

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 1

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 1

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 1

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 4

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 3

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 3

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 2

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 2

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 3

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 3

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 3

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 1

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 7 in /home/julian99/public_html/pug/includes/functions/general.php(105) : regexp code on line 3

 

And it goes on for miles and miles.....

 

It doesn't happen when searching thru Advanced Search. If I use quotation marks and search even thru titles only...the search results are fine and the items, when clicked on, view properly. No errors.

 

No problems in Advanced Search using quotation marks and searching thru product descriptions, either. No highlighting, but...no errors.

 

I temporarily installed something I found in the contribs section; an Advanced Searchbox which incorporates titles AND descriptions into the search function. But, that's when I discovered the problem with quotation marks and put my 'old' searchbox back.

 

My buyers very much need to search with quotation marks. You can just imagine how difficult their searches will be looking for an actor named David Tom. Without the quotes, they're pulling up everything that mentions David Somebody and Tom Somebody...much less David Tom. You get the idea.

 

I'm sorry to say it, but...I need some more help!!!

Link to comment
Share on other sites

Ignore my previous post. I see what's wrong now.

 

Your website, Boxtel, has advanced search 'incorporated' into the search box. Mine does not.

 

The highlighting IS occuring only when using the search box on the left side of my homepage.

 

But, when I go into Advanced Search, and select the box to search in product descriptions...there's no highlighting. How do I achieve THAT?

 

At present, the highlighting only occurs when searching thru product titles only. The keywords will be highlighted in the title AND the item description.

 

But...not when using Advanced Search to look for keywords WITHIN titles AND item descriptions.

 

Good Lord...I'm almost there!!!!!!!!

 

you apply the same change in advanced_search.php:

 

replacing

 

tep_hide_session_id()

 

with:

 

tep_hide_session_id() . tep_draw_hidden_field('hl',1)

 

I personally have a checkbox on advanced_search so you can turn it on/off but the change above will turn it on permanently.

Treasurer MFC

Link to comment
Share on other sites

Okay....I changed that line in Advanced_Search.php and now there is highlighting for those search returns.

 

However, I still have the HUGE problem of not being able to use quotation marks when searching.

 

What happens is this:

 

In Advanced Search, I type in an actor's name...."Don Diamont" for example, in quotes as I just did.

 

I click Search. Accurate search returns are generated. X number of items containing the string Don Diamont. Looks fine.

 

But, when I click on any of the items returned, I get that disaster unfolding on my screen of nonstop errors in functions/general.php as I posted above last evening.

 

When I put quotes around my keywords, it generates a URL that ends like this:

 

&keywords=\"Don%20Diamont\&quot

 

When I do the same in your website, Amanda...I searched on "gold earrings' in quotes

 

I get a URL that looks like this: &keywords=%22gold+earrings%22

 

And no errors, lots of highlighting, etc. In other words, I can use quotes in your site when searching; but at present, I cannot in mine.

 

Not being able to search with keywords in quotation marks in order to pull up exact strings will kill my site.

 

PLEASE help me fix this...and we're all done!!!!!!!

Link to comment
Share on other sites

Okay....I changed that line in Advanced_Search.php and now there is highlighting for those search returns.

 

However, I still have the HUGE problem of not being able to use quotation marks when searching.

 

What happens is this:

 

In Advanced Search, I type in an actor's name...."Don Diamont" for example, in quotes as I just did.

 

I click Search. Accurate search returns are generated. X number of items containing the string Don Diamont. Looks fine.

 

But, when I click on any of the items returned, I get that disaster unfolding on my screen of nonstop errors in functions/general.php as I posted above last evening.

 

When I put quotes around my keywords, it generates a URL that ends like this:

 

&keywords=\"Don%20Diamont\&quot

 

When I do the same in your website, Amanda...I searched on "gold earrings' in quotes

 

I get a URL that looks like this: &keywords=%22gold+earrings%22

 

And no errors, lots of highlighting, etc. In other words, I can use quotes in your site when searching; but at present, I cannot in mine.

 

Not being able to search with keywords in quotation marks in order to pull up exact strings will kill my site.

 

PLEASE help me fix this...and we're all done!!!!!!!

 

well, that is a problem in your tep_href_link function which apparently uses the htmlspecialschars() or the htmlentities() function on your parameters. Those would translate " into &quote;

Maybe a contrib you are using?

Treasurer MFC

Link to comment
Share on other sites

Well, seeing as all of my errors are referencing functions/general.php, I thought I would start by looking there.

 

I see the following near the top of my general.php file. Has nothing to do with a contrib; it's a chunk of code that came with the install of OSC.

 

////

// Parse the data used in the html tags to ensure the tags will not break

function tep_parse_input_field_data($data, $parse) {

return strtr(trim($data), $parse);

}

 

function tep_output_string($string, $translate = false, $protected = false) {

if ($protected == true) {

return htmlspecialchars($string);

} else {

if ($translate == false) {

return tep_parse_input_field_data($string, array('"' => '"'));

} else {

return tep_parse_input_field_data($string, $translate);

}

}

}

 

Am I in the ballpark? If so, how do I edit this?

Link to comment
Share on other sites

Well, seeing as all of my errors are referencing functions/general.php, I thought I would start by looking there.

 

I see the following near the top of my general.php file. Has nothing to do with a contrib; it's a chunk of code that came with the install of OSC.

 

////

// Parse the data used in the html tags to ensure the tags will not break

function tep_parse_input_field_data($data, $parse) {

return strtr(trim($data), $parse);

}

 

function tep_output_string($string, $translate = false, $protected = false) {

if ($protected == true) {

return htmlspecialchars($string);

} else {

if ($translate == false) {

return tep_parse_input_field_data($string, array('"' => '"'));

} else {

return tep_parse_input_field_data($string, $translate);

}

}

}

 

Am I in the ballpark? If so, how do I edit this?

I have the very same function so I doubt the problem is there.

Treasurer MFC

Link to comment
Share on other sites

This is all I can come up with. It relates to product_listing.php

 

I had the contrib Search Results Highlight 1.1 in there. I took it out, but...when I was playing with the code you were giving me to install, I think I did something I shouldn't have.

 

Initially, after I removed that contrib and put back the file the way it was initially, I was messing around with your code, trying to get it to work, and I deleted something thinking it wouldn't matter. That chunk of code initially read like this:

 

case 'PRODUCT_LIST_NAME':
		if ($HTTP_GET_VARS['manufacturers_id']) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id'], 'NONSSL') . '">' . $listing['products_name'] . '</a>';
		} else {
		  $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';
		}
		break;

 

See all of those references to manufacturers? I took it out. And replaced that chunk of code with this:

 

case 'PRODUCT_LIST_NAME':
		if ($display_search_results) { 
$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id'] . $parm_add) . '">' . highlight_viewable_text($listing['products_name'], $HTTP_GET_VARS['keywords'], 'searchTag') . '</a> ';
		} else { 
					$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';
		}
		break;

 

Could that be it? And if so, what should I put in the file to replace the above, what I have now?

Link to comment
Share on other sites

I don't know if what I said above is problematic or not. I just tried to search with quotes again and when I click on any of the results returned...all of the error messages are off line 105 in my functions/general.php file

 

And that line is part of the 2nd function of yours, Boxtel, that I inserted in the code. I used that follow up post of yours at the beginning of this thread to use that function...this one:

 

function highlight_text ($text, $token, $class) {

$text = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $token . ")\b#i', '<span class=\"" . $class . "\">\\\\1</span>', '\\0')", '>' . $text . '<'), 1, -1));

return $text;

}

 

That's where the error is occuring, where the 2nd line of that code begins.

 

Everything's fine when I search in quotation marks initially. Accurate results are being returned. It's just when I click on any of the items returned that it falls apart.

Link to comment
Share on other sites

Well, HOLY COW!!!!!

 

Boxtel: Remember when you made your first post in this thread and you said that 2 new functions needed to be added to general.php and then...you followed up with another post saying, no, this one works better?

 

I had put in that one from your 2nd post. I took the first one from your first post...and then added the 'better one' from your 2nd post. Hope I'm making sense.

 

I've been tearing my hair out trying to diagnose it with as little as I know...and I thought...maybe I should try that first one she was using. The 2nd one in the 1st post, as opposed to the replacement you said was better in your follow-up post. At the same time, I thought....gosh, haven't I done that already? Haven't I tried that already?

 

But, I'm so tired and nuts over it all, I went ahead and did it anyway.

 

Now...the items that appear in search returns are viewable. But....no highlighting.

 

I'm thrilled that I'm not seeing error messages now. But....the highligting effect has disappeared from those items. Only when using quotation marks to pull up items in Advanced Search.

Link to comment
Share on other sites

Well, given how quiet you've been since my last post, I expect you're fed up with me, Boxtel.

 

I can't blame you; I know I'm terrorizing you over this highlight enhancement.

 

But...I'm so close I can't quit, either.

 

I installed another searchbox this evening that defaults to search in both titles and descriptions. Very cool, very easy. Here's the link to the contrib if anyone is interested:

 

Advanced Searchbox

 

You know, these things...these tiny problems...always turn out to be something silly and simple. So...I can't stop trying to figure out how to get this to work.

 

At present, I can search in titles & descriptions with no quotation marks surrounding my keywords and those keywords are highlighted in titles and descriptions. Beautiful. But...still no highlighting when using quotation marks around keywords when searching for an exact string of words.

 

Something interesting happened when I switched out your functions last night, too.

 

Initially, I was using your first function from your 1st post and the 2nd function came from your follow-up post. Looked like this:

 

function highlight_viewable_text ($text, $keywords, $class) {
if (($text == '') or ($keywords == '')) return $text;
if (!($check = tep_parse_search_string($keywords, $search_keywords))) return $text;
$strip_array = array('and', 'or', 'AND', 'OR');
$result = $text;
for ($i = 0; $i<sizeof($search_keywords); $i++) {
if (!in_array($search_keywords[$i], $strip_array)) {
$result = highlight_text($result, $search_keywords[$i], $class);
}
}
return $result;
}

function highlight_text ($text, $token, $class) {
$text = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $token . ")\b#i', '<span class=\"" . $class . "\">\\\\1</span>', '\\0')", '>' . $text . '<'), 1, -1));
return $text;
}

 

But, that 2nd function was wrecking my product listings. Nothing but errors all over the screen...but only when I surrounded my keywords with quotation marks. So, I replaced that chunk of code with your 2 original functions from your 1st post in this thread:

 

function highlight_viewable_text ($text, $keywords, $class) {
if (($text == '') or ($keywords == '')) return $text;
if (!($check = tep_parse_search_string($keywords, $search_keywords))) return $text;
$strip_array = array('and', 'or', 'AND', 'OR');
$result = $text;
for ($i = 0; $i<sizeof($search_keywords); $i++) {
if (!in_array($search_keywords[$i], $strip_array)) {
$result = highlight_text($result, $search_keywords[$i], $class);
}
}
return $result;
}

function highlight_text ($text, $keywords, $class) {
$keywords = strtolower($keywords);
$token = strtoupper($keywords);
$text = preg_replace('/(?!<.*?)(' . preg_quote($token, '/') . ')(?![^<>]*?>)/si','<span class="' . $class . '">' . $token . '</span>',$text);
$token = $keywords;
$text = preg_replace('/(?!<.*?)(' . preg_quote($token, '/') . ')(?![^<>]*?>)/si','<span class="' . $class . '">' . $token . '</span>',$text);
$token = ucwords($keywords);
$text = preg_replace('/(?!<.*?)(' . preg_quote($token, '/') . ')(?![^<>]*?>)/si','<span class="' . $class . '">' . $token . '</span>',$text);
return $text;
}

 

Now, functions/general.php looks like that. Glad I did. No more errors when clicking to view a product listing after searching with keywords surrounded by quotes. But...no highlighting, either, when surrounding keywords in quotation marks.

 

The interesting thing it is doing...is that words I have in all capital letters in the title are now being changed. If the word or words is highlighted....instead of reading as YOUR NAME they read as Your Name. No biggie, but...I wonder why that's happening, too.

 

In one of your last posts, you suggested that perhaps a contrib was butting heads with this. I don't know. I mean, I don't have the most heavily modified site on the planet. Yours appears to be 'heavily modified' to me. I just have this:

 

Header Tags Controller

Credit Class/Gift Voucher 5.10

Purchase Without Account

Current Auctions (which just displays my live eBay listings)

Froogle Data Feeder (modified to upload to Googlebase)

Out Of Stock (not sure if that's the name...it simply replaces item quantities with In or Out of Stock)

 

That's about it. Other than the new searchbox I installed this evening.

 

I feel stuck and have no idea what direction to go in and I'd appreciate some guidance; some idea of what to look for or do to get this right. This feature will rock if I can get it to work with keywords surrounded by quotation marks. That's all that's left! If I can fix that...it will be terrific!

Link to comment
Share on other sites

Hello, Boxtel. Me again. I still haven't been able to resolve my problem with quotation marks.

 

So, I thought I would install OSC on one of my sub-domains and play with a fresh, clean install of OSC with no contribs. Surely, this should work there, right?

 

Well....your first two functions in post #1, when used together, produce the following errors:

 

Warning: session_start() []: Cannot send session cache limiter - headers already sent (output started at /home/julian99/public_html/test/includes/functions/general.php:81) in /home/julian99/public_html/test/includes/functions/sessions.php on line 97

 

Fatal error: Call to undefined function: tep_not_null() in /home/julian99/public_html/test/includes/functions/html_output.php on line 18

 

So, I get rid of that 2nd function in your first post and replace it with the 'better' one in your follow up post. Okay, THAT works. To an extent.

 

Keywords are highlighted when searching thru titles. Keywords are highlighted in the body of the item description...when not using quotation marks around those keywords. However, when searching thru titles only OR searching in product descriptions via Advanced Search WITH quotation marks around keywords, there is no highlighting and I'm getting those weird backslashes in front of the keywords in the URL, just as I am presently in my live site.

 

Looks like this: products_id=28&keywords=\"keyword%20keyword\"&hl=1

 

Here's the link to my test site if you'd like to take a look: Test Site

 

No contribs, no nothing. All I've done is follow the instructions again in this thread to try and get highlighting to work there. The highlight color I'm working with there is red.

 

What I had intended to do was install the highlighting code and then install the contribs I'm using on my live site, one at a time, to troubleshoot and see which contrib may be causing the problem. But, I can't get this to work on a clean install, either.

 

I don't know if it means anything, but the way I enable search to be conducted with quotation marks is by going into advanced_search_result.php and editing a chunk of code near the top of the file that originally looks like this:

 

 if (isset($HTTP_GET_VARS['keywords'])) {
  $keywords = $HTTP_GET_VARS['keywords'];
}

 

and adding the word 'stripslashes' so it now looks like this:

 

 if (isset($HTTP_GET_VARS['keywords'])) {
  $keywords = stripslashes($HTTP_GET_VARS['keywords']);
}

 

Could that have anything to do with anything? It's the only way I'm aware of to enable searches to be conducted with quotation marks around keywords. I hope you come back to help, Boxtel. I need it. :)

Link to comment
Share on other sites

the quotes in the keywords is a separate issue not a highlight issue:

 

here is what I have done to fix the quoted keywords issue on my site

(it's more of a hack than a perfect solution)

 

in catalog/advanced_search_result.php find

 

	if (isset($HTTP_GET_VARS['keywords'])) {
  $keywords = $HTTP_GET_VARS['keywords'];
}

 

and change to:

	if (isset($HTTP_GET_VARS['keywords'])) {
$keywords = $HTTP_GET_VARS['keywords'];

// added to remove quotes and replace spaces with 'and'
if (strpos($keywords, '"')){
$keywords = str_replace('\"','',$keywords);
$keywords = str_replace(" ", " and ", $keywords);
}
// end added

}

Link to comment
Share on other sites

Thanks, Jeff.

 

I put that code of yours in and replaced my previous code with the 'stripslashes' in it, and I'm still getting the same result when searching with quotation marks.

 

products_id=28&keywords=\"keyword%20keyword\"&hl=1

 

It's not removing the slashes created in the URL.

 

I see what it's doing when I type in, for example, "Peter Bergman" in the box and click to search in Advanced Search, it's changing the request in the searchbox to Peter and Bergman. The problem is product_info.php...that's the file that is adding those slashes.

 

When I click on the item returned in the search results screen, the product_info screen comes up and it changes what's in the search box from Peter and Bergman to \"Peter Bergman\"

 

But, even before that, his name should have been highlighted in the advanced_search_results screen since his name is in the title of a listing I threw in there, and it's not highlighting there, either. It will highlight when searching without quotation marks, though.

 

I don't know what to make of it. At this point, I wonder if Boxtel has created something that works beautifully within her own site, but...may not be something that can be universally applied to other OSC sites. I don't know. I appreciate the help, Jeff!

Link to comment
Share on other sites

Thanks, Jeff.

 

I put that code of yours in and replaced my previous code with the 'stripslashes' in it, and I'm still getting the same result when searching with quotation marks.

 

products_id=28&keywords=\"keyword%20keyword\"&hl=1

 

It's not removing the slashes created in the URL.

 

I see what it's doing when I type in, for example, "Peter Bergman" in the box and click to search in Advanced Search, it's changing the request in the searchbox to Peter and Bergman. The problem is product_info.php...that's the file that is adding those slashes.

 

When I click on the item returned in the search results screen, the product_info screen comes up and it changes what's in the search box from Peter and Bergman to \"Peter Bergman\"

 

But, even before that, his name should have been highlighted in the advanced_search_results screen since his name is in the title of a listing I threw in there, and it's not highlighting there, either. It will highlight when searching without quotation marks, though.

 

I don't know what to make of it. At this point, I wonder if Boxtel has created something that works beautifully within her own site, but...may not be something that can be universally applied to other OSC sites. I don't know. I appreciate the help, Jeff!

 

try this:

 

find :

 

if (tep_not_null($keywords)) {

if (!tep_parse_search_string($keywords, $search_keywords)) {

$error = true;

 

$messageStack->add_session('search', ERROR_INVALID_KEYWORDS);

}

}

 

 

and make that :

 

if (tep_not_null($keywords)) {

if (!tep_parse_search_string(stripslashes($keywords), $search_keywords)) {

$error = true;

 

$messageStack->add_session('search', ERROR_INVALID_KEYWORDS);

}

}

 

 

$search_keywords is the array which is parses the keyword string via spagetti-code into an array of separate keywords, including "(", "and", "or", ")" operators.

 

if the string is "keyword keyword" then

without stripping of slashes, that array would contain [\"][keyword][and][keyword][\"] and it will not find anything.

 

with stripping it will be come [keyword keyword] and it should be fine.

Treasurer MFC

Link to comment
Share on other sites

I'm sorry, Boxtel, but that doesn't work, either.

 

I changed that code as you said in advanced_search_result.php (I assume that's the only file?) and it's still generating those slashes in the URL when searching with quotation marks.

 

Result looks like this: products_id=28&keywords=\"keyword%20keyword\"&hl=1

 

Didn't change anything in the test site or my live site. Here's the link for the test site, the clean install of OSC:

 

Test Site

 

Are we having fun yet? And, hey...THANK YOU for coming back to this thread. :)

Link to comment
Share on other sites

I'm sorry, Boxtel, but that doesn't work, either.

 

I changed that code as you said in advanced_search_result.php (I assume that's the only file?) and it's still generating those slashes in the URL when searching with quotation marks.

 

Result looks like this: products_id=28&keywords=\"keyword%20keyword\"&hl=1

 

Didn't change anything in the test site or my live site. Here's the link for the test site, the clean install of OSC:

 

Test Site

 

Are we having fun yet? And, hey...THANK YOU for coming back to this thread. :)

 

yes, that should not matter that much as the function strips those before the tring is parsed.

 

you could do 2 things:

 

1)check in php.ini if you have this:

magic_quotes_gpc = Off

 

if it is on then all GET/POST/COOKIE stuff will be automatically escaped as you seem to have.

 

2)

 

just after the code segment

 

if (tep_not_null($keywords)) {

if (!tep_parse_search_string(stripslashes($keywords), $search_keywords)) {

$error = true;

 

$messageStack->add_session('search', ERROR_INVALID_KEYWORDS);

}

}

 

add:

 

print_r($search_keywords);

 

that should print the array values of the individual keyword components as parsed by that function.

Then you can see what the different keywords come down to.

Mind you, that parse function is not perfect.

Treasurer MFC

Link to comment
Share on other sites

When I add that print command and search for "Peter Bergman" in the test site, it's printing this at the top of the screen:

 

Array ( [0] => peter bergman )

 

But, what does that mean?

 

As for the php.ini file, I don't have access to that. That's in the web server directory, correct? Not within my own OSC file structure?

Link to comment
Share on other sites

When I add that print command and search for "Peter Bergman" in the test site, it's printing this at the top of the screen:

 

Array ( [0] => peter bergman )

 

But, what does that mean?

 

As for the php.ini file, I don't have access to that. That's in the web server directory, correct? Not within my own OSC file structure?

 

that is perfect

Treasurer MFC

Link to comment
Share on other sites

My webhost told me I could disable that by putting the following in the .htaccess file:

 

php_flag magic_quotes_gpc Off

 

That doesn't work, either. What do I do now?

Link to comment
Share on other sites

For what it's worth, I just want to add this in the hopes that it may help Boxtel to further diagnose what's happening.

 

When I put that line...php_flag magic_quotes_gpc Off...in the root folder/htaccess file, it DID have an effect on the search box itself.

 

All this time...when I type in "Peter Bergman" in quotes, the searchbox would reflect that until I clicked on the item itself and then the searchbox would say \"Peter Bergman\".

 

That entry in the htaccess file stopped that. Now, the search box reflects exactly what I typed in...."Peter Bergman"

 

Unfortunately, the URL being generated by the product itself still contains those slashes, thusly....killing any highlight effect.

 

Perhaps there's something I need to add to product_info.php to put a stop to this?

Link to comment
Share on other sites

Well, somebody buy me a beer! I fixed it!

 

Turns out that Magic_Quotes_GPC being on or off is irrelevant. I put a command in the .htaccess file to turn off or 'override' magic_quotes and it did nothing, really. So, I abandoned that in a hurry and took that code out of the .htaccess file. All of my trouble searching and getting highlighting with quotes around keywords boiled down to one little word that needed to be added to Boxtel's chunks of code in product_info.php and product_listing.php

 

stripslashes

 

That's all it was. Anywhere in her code where you see the following:

 

either $GET or (for me) $HTTP_GET_VARS['keywords']...all I had to do was put the word stripslashes in front of it and it would turn out like this:

 

stripslashes($HTTP_GET_VARS['keywords'])

 

All done. That's all it was. I'm so relieved it isn't even funny.

 

But, Boxtel....I need you for one last whirl. My live site. Works fine until I get to an item description.

 

It IS highlighting keywords in titles when searching with quotes, but not in descriptions. The descriptions are not blowing up anymore as they were previously, either. They appear just fine, but...no highlighting in the description.

 

URLs being generated look like this:

 

products_id=919&keywords="Peter%20Bergman"&hl=1

 

So...I see that '&quot' reference at the top of functions/general.php which reads like this:

 

 function tep_output_string($string, $translate = false, $protected = false) {
if ($protected == true) {
  return htmlspecialchars($string);
  } else {
  if ($translate == false) {
	return tep_parse_input_field_data($string, array('"' => '&quot'));
	} else {
	return tep_parse_input_field_data($string, $translate);

 

So, just for the fun of it...I change '&quot' to '%20' since I see that in other places, and now it IS highlighting the keywords in the item description, but not just the exact string that I typed in with quotes. In other words, if I type in "Peter Bergman" it will return EXACT search results (everything that exact search string is in)...but the highlighting within the body of the item descriptions are not just picking up Peter Bergman. It's highlighting everyone else named Peter, too. Hope I'm making sense. It's not that a big a deal, really...just puzzling.

 

I realize that I must have some contrib that's giving me a problem with regards to '&quot' but...I'd prefer to find a simple workaround, if possible, rather than having to install some pretty large contribs in the test site to see where that problem is coming from.

 

Is there anything I could do with that function to get rid of that '&quot' or is that wishful thinking? For the meantime, I'll leave it at '%20' as it doesn't appear to hurt anything and it does provide keyword highlighting within the item descriptions when searching with quotation marks around keywords.

 

The only trouble I see is when searching on a word or phrase that has an apostrophe. That generates errors with your function in post #2, but...there's no need for anyone to be searching in that way, so...I'll just leave it be until I figure out what to do about that.

Link to comment
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...