You are here:  » Search Tags

Support Forum



Search Tags

Submitted by webie on Sun, 2008-10-26 18:01 in

Hi Dave,

I wonder if you can point me in the right direction to create seo url search tags
lets say we have product name like so:

Arc Welder 150Amp with Accessory Kit

I want to split the product name into single word chuncks excluding any stop words such as and, for etc.

Then i want to enable search word tags so each tag become searchable word then the user click on the word to search products using these tags also instead of using the default url like so 'search/relevance/arc/' i would like url to be so /search/relevance/tag/arc/

Kind Regards

Darren

Submitted by support on Mon, 2008-10-27 11:03

Hello Darren,

Have you already implemented re-written search URLs of the form you describe; as per this thread:

http://www.pricetapestry.com/node/1727

First step would be to add another rewrite rule to effectively "ignore" the word tag. To do this, try adding the following immediately BEFORE the other search rewrite rules:

RewriteRule ^search/relevance/tag/(.*)/$ search.php?sort=relevance&q=$1&rewrite=1&%{QUERY_STRING} [L]

(all on one line)

Having implemented this, you could then add the following code to the bottom of products.php (for example after the line to include related products) to link the tags to the above rewritten search URL:

  if ($q)
  {
    print "<p>";
    $words = explode(" ",$q);
    foreach($words as $word)
    {
      $href = $config_baseHREF."search/relevance/tag/".urlencode($word)."/";
      print "<a href='".$href."'>".$word."</a>&nbsp;";
    }
    print "</p>";
  }

Hope this helps!

Cheers,
David.

Submitted by webie on Mon, 2008-10-27 13:15

Hi Dave,

Worked perfect great just one more thing can we remove stop words like more and at so etc a wile ago you created function tapestry_highlight($text,$words) for me can i pass that fuction to remove stop words from search tags with this function

Kind Regards

Darren

Submitted by support on Mon, 2008-10-27 13:27

Hi Darren,

Stop words are easily incorporated as follows - just edit / add to the $stopWords array...

  if ($q)
  {
    $stopWords = array("the"=>1,"and"=>1,"to"=>1); // etc.
    print "<p>";
    $words = explode(" ",$q);
    foreach($words as $word)
    {
      if ($stopWords[strtolower($word)]) continue;
      $href = $config_baseHREF."search/relevance/tag/".urlencode($word)."/";
      print "<a href='".$href."'>".$word."</a>&nbsp;";
    }
    print "</p>";
  }

Cheers,
David.

Submitted by webie on Mon, 2008-10-27 14:10

Hi Dave,

Got small problem after enabling search tags it seems i have lost my merchant logo images? some are blank some half loaded?

Regards

Darren

Submitted by support on Mon, 2008-10-27 14:11

Hi Darren,

Sounds strange - could you quickly comment out the above code from your product page and confirm that it's definitely related to having added this...?

Cheers,
David.

Submitted by webie on Mon, 2008-10-27 14:20

Hi Dave,

Sorry to be pain found one more problem page sort not working either if i do normal search then go to product page then click on search tag all display ok but when i click on page to products not found i see this in search bar 'tagWelder'

url is like so /search/relevance/tag/Welder/2.html

Regards

Darren

Submitted by support on Mon, 2008-10-27 14:24

Hi Darren,

Ooops - I'd missed off the second tag rewrite for the additional pages.. Try adding this just after where you added the other rewrite rule for this from above:

RewriteRule ^search/relevance/tag/(.*)/(.*).html$ search.php?sort=relevance&q=$1&page=$2&rewrite=1&%{QUERY_STRING} [L]

Cheers,
David.