So I took your advice and did a search and viewed the code. I think I have a solution that will work for me, but is far from "contribution' material yet...
Note: I am running Zen 1.3.7 so that is the platform these changes were made with.
What this does: When you click on a category this checks if the category description exists and also checks how many products are in the category. If there are 0 products and there is a category description the script assumes you want to do a advanced search using the text you place in the category description field. If there are more than 0 products in the category the normal product results are returned.
So for example: say you want to create a 'search category' for the term "ducks". You would first do a advanced search from your store catalog for the search term "ducks". To make the search even better you could do a search for perhaps "ducks or duckies" (leave our the quotes when doing your search). The results are of course any products from your catalog that contain the words "ducks" or "duckies". So now you copy from the URL starting with "advanced_search_result" and everything after that to the clipboard:
http://www.YOUR_STORE/index.php?main_page=advanced_search_result&keyword=ducks+or+duckies&search_in_description=1&categori es_id=&inc_subcat=1&manufacturers_id=&pfrom=&pto=&dfrom=&dto=&x=0&y=0
Now to complete this example you would create a new category, perhaps named "Ducks and Duckies" (the name does not matter) and you would paste the contents of the clipboard to the categories description field. Save the category. Now when you click on the category "Ducks and Duckies" from your storefront you are really seeing a search query for the terms you created from your advanced search result.
You can do the same for any search criteria, for instance if you wanted to show all products between $1 and $50 you could do that too.
Something to note is of course it would be better to create a new category field - something like "search terms"... or maybe even a few more category fields like "price from" and "price to" to avoid having to hijack the categories description field for this. Maybe someone can do that or if I find the time I could take a crack?
So here are the changes you will need to make to make this work for you: (no files are edited unless you already have a copy of tpl_index_product_list.php or advanced_search_result.css in your custom_template folders. Also no edits to the DB (yet!)
To add "search categories" functionality to your Zen Cart:
Step 1: Edit /includes/templates/your_template/templates/tpl_index_product_list.php (if this file does not exist copy it from /includes/templates/template_default/templates to /includes/templates/your template/tpl_index_product_list.php)
Find the following code:
Code:
<?php
// categories_description
if ($current_categories_description != '') {
?>
<div id="indexProductListCatDescription" class="content"><?php echo $current_categories_description; ?></div>
<?php } // categories_description ?>
Replace it with:
Code:
<!-- CGR - Begin Categories Search Function -->
<?php include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING)); ?>
<?php
// categories_description
if ($current_categories_description != '') {
// CGR - This next line will tell us if there are any products in the category, if there are none then don't show the description
if ($listing_split->number_of_rows > 0) {
?>
<div id="indexProductListCatDescription" class="content"><?php echo $current_categories_description; ?>
</div>
<?php }} // categories_description ?>
<div id="categoriessearchresults">
<?php
$categories_search_url = HTTP_SERVER . DIR_WS_CATALOG . 'index.php?main_page=' . $current_categories_description;
?>
<?php
// categories_description
if ($current_categories_description != '') {
if ($listing_split->number_of_rows == 0) {
?>
<?php include ($categories_search_url); ?>
<?php }} // categories_description ?>
</div>
<!-- CGR - END Catagories Search Function -->
Step 2: Create /includes/templates/your_template/css/advanced_search_result.css
Step 3: Copy the following CSS to your newly created CSS file:
Code:
#categoriessearchresults #headerWrapper, #categoriessearchresults #navColumnOne, #categoriessearchresults #navColumnTwo, #categoriessearchresults #navSuppWrapper, #categoriessearchresults #siteinfoLegal, #categoriessearchresults #navBreadCrumb {
display:none;
}
#categoriessearchresults .messageStackWarning, #categoriessearchresults .buttonRow {
display:none;
}
#categoriessearchresults .centerColumn {
width: 90%; color: purple;
}
Note: I made the color of the search results text purple so you can see the difference between a normal categories products result and a categories search result.