I did some experimenting and was able to create a page template and a product template that could automatically generate search links. It requires some setup but once done it wouldn't be hard to include it on all the pages in your store.
For this to work you need to create a new page template with just the [-- DEFINE LINK_TO_PAGE --] section as outlined below. You would also need to use one of the custom page fields to indicate that the page is to be used for a "search category" page. The example uses the page extra field 1. The page template with this define link to page section is named search-category which will be used to specify that template for the links in the loop links section. You would assign the search category pages to what ever pages you want the search links to appear on. The search term will be the page name.
- Code: Select all
[--DEFINE LINK_TO_PAGE--]
[-- if page.field1 "search category" --]
<form action="[-- SHOPPING_CART_URL Base --]/productsearch.cgi?storeid=[-- STORE.ID --]" method="get">
<input name="storeid" value="[-- STORE.ID --]" type="hidden">
<div id="search">
<input value="[-- page.name --]" id="search_field" name="search_field" type="hidden">
<input value="[-- page.name --]" id="search_button" type="submit">
</div>
</form>
<br>
[-- end_if --]
[--END_DEFINE LINK_TO_PAGE--]
Then in your normal page template where you want the search links to appear you would put the following code. Note the template override of "search-category" ,
- Code: Select all
[-- loop links --]
[-- link search-category --]<br>
[-- end_loop links --]
To use products as the "search category" values you could do it like this. (again using the product extra field1 for "search category" and the product template named search-category so you can override the default template with this special one.
- Code: Select all
[-- DEFINE PRODUCT --]
# product template just for search links.
[-- if product.field1 "search category " --]
<form action="[-- SHOPPING_CART_URL Base --]/productsearch.cgi?storeid=[-- STORE.ID --]" method="get">
<input name="storeid" value="[-- STORE.ID --]" type="hidden">
<div id="search">
<input value="[-- product.name --]" id="search_field" name="search_field" type="hidden">
<input value="[-- product.name --]" id="search_button" type="submit">
</div>
</form>
<br>
[-- end_if --]
[-- END_DEFINE PRODUCT --]
If using the product method you would assign the search category products to the page and then on the page template where you want the search links to go you would have the following code. Note that the product name will be used for the search term.
- Code: Select all
[-- loop products--]
[-- product search-category --]<br>
[-- end_loop products --]
Hope that gives you some ideas of how this could be used.