View Single Post
  #12  
Old 05-11-2010, 05:09 PM
 
TheWrongGrape TheWrongGrape is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: Los Angeles, CA
Posts: 68
 

Default Re: Show search keywords in description of product

Got this working on 4.3.1. I'm using my Search Keywords as "Tags" to encourage customers to browse more.

After searching for clickable search keywords, I got a lot of help from this thread by wjbrewer.

Please read that over first.

Firstly, I didn't need to mod my search so you can ignore the part about that.

In product.php, where wjbrewer indicated, I pasted in:

Code:
$keywords = split(",", $product_info['keywords']); $smarty->assign('keywords', $keywords);

The above is different from what wjbrewer originally posted in that it recognizes that my keywords are comma-separated and will break them up as such, including keyword phrases that consist of more than one word with spaces in between.

Then in my template where I want the keywords to show up (/customer/main/products_details.tpl in my case), I put in the following which will return my keywords on one line, followed by a pipe symbol (except for the last value) and each will be turned into a link:

Code:
{if $product.keywords ne ""} Tags: {foreach from=$keywords item=keyword name=kw} <a href="../search.php?mode=search&by_title=Y&by_descr=Y&by_sku=Y&search_in_subcategories=Y&including=all&substring={$keyword}">{$keyword}</a> {if !$smarty.foreach.kw.last}| {/if} {/foreach}{/if}

The end result looks like this:

Tags: Feminine | Floral | Sweet and Sassy

Hope this helps someone!
Reply With Quote