For simple sites that don't use sub-categories, etc, this may come in handy! Further, this was my first success at defining a Smarty var in the actual .TPL template file, then referencing back in php. I'm sure there is an easier way to do this, but this was my first successful attempt.
A request was made to have all of our category links on the left link directly to the individual product page when there is only one product in the category.
Adding the following code to the top of
skin1/customer/main/subcategories.tpl does the trick!
Thanks to darrenkierman for pointing out that adding the following code to the top of
skin1/customer/main/search_result.tpl will also take you straight to the product page if your search returns only 1 result!
Code:
{if $products|@count eq 1}
{assign var="prodURL" value="product.php?productid=`$products.0.productid`&cat=$cat&page=1"}
{php}
header( "Location: " . $GLOBALS[smarty]->_tpl_vars[prodURL] );
{/php}
{/if}