You are here:  » Allowed characters in title and search


Allowed characters in title and search

Submitted by mikecdprice on Tue, 2013-07-30 07:29 in

Hello David,

I am working on a site that I need $, . , % in the and search bar as allowed characters. I have found threads that are 5 years old on this topic. For example like says only $34.99 and the title says only 3499 ;)

How do I fix this?

Any idea?

Submitted by support on Tue, 2013-07-30 08:45

Hi Mike,

Just as per your question regarding date search, to permit those characters ("." should be permitted already let me know if that's not the case after this mod you may have other changes in place removing it) use the following replacement at line 6 of search.php (includes the "/" character from the other thread)

  $q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\./$%"):"");

Cheers,
David.
--
PriceTapestry.com

Submitted by mikecdprice on Tue, 2013-07-30 16:18

Hello David,

This one did not work. It gives me 0 search results of a blank screen when added. I was able to follow directions on another thread on the search.php but I am not able to correct the titles on the products.php as it is excluding - , . , %, $ -- Those types of things

How do I fix that on the products detail pages. I can do the search.php just fine

Thank you

Submitted by support on Tue, 2013-07-30 17:20

Hi Mike,

"$" actually needed to be escaped in the expression, sorry about that - have a go with;

  $q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\.\/$%"):"");

For testing purposes, if you wanted to allow everything, you could just use:

  $q = (isset($_GET["q"])?$_GET["q"]:"");

Cheers,
David.
--
PriceTapestry.com

Submitted by mikecdprice on Tue, 2013-07-30 19:18

Hello David,

That works perfect on the search.php pages, titles and etc.

I cannot get the code to work on the products.php page it still removes all the characters. Is it possible to all the characters in the title as a blog like title as I know it is very cleaned up.

Thank you,
Michael

Submitted by mikecdprice on Tue, 2013-07-30 19:19

It might be the if q statements not showing the info in this case

Submitted by support on Tue, 2013-07-30 19:52

Hi Mike,

The product name (also q= in the query string, either directly or re-written) is normalised in exactly the same way in products.php - at line 4:

  $q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\."):"");

...so you could use the same working version as above;

  $q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\.\/$%"):"");

...or the unrestricted option (same code as above)

Cheers,
David.
--
PriceTapestry.com

Submitted by mikecdprice on Tue, 2013-07-30 20:47

Hello David,

I tried all three ways on the products.php and it still removes the characters showing 3999 intead of $39.99 Some parts of the page show the characters, the , meta, value in search box and h2 title all show it removed without the characters.

I was not sure if the

if ($q)
{
$banner["h2"]

overwrote the $q as it was used instead while other parts on the page used the line 4

Submitted by support on Wed, 2013-07-31 08:29

Hi Mike,

If you move the $banner["h2"].... line down to where $header["title"] is set, and then in both cases, use the product name from the result set rather than $q (which is the normalised name) - for example:

    $banner["h2"] = translate("Price search results for")." <strong>".htmlspecialchars($product["products"][0]["name"],ENT_QUOTES,$config_charset)."</strong>&nbsp;";
    $header["title"] = $product["products"][0]["name"];

Cheers,
David.
--
PriceTapestry.com

Submitted by mikecdprice on Wed, 2013-07-31 14:35

Hello,

Wonderful, Thank you. It works perfect

Thank you,
Michael