![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
#1
IP: 192.240.127.74
|
|||
|
|||
|
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}
|
|
#2
IP: 192.240.127.74
|
|||
|
|||
|
One small bug .... lets say you have one product and 5 subcategories, it will not show the subcategories because it automatically jumps to the one product. To fix it :
Code:
{if $products|@count eq 1}
{if $subcategories}{else}
{assign var="prodURL" value="product.php?productid=`$products.0.productid`&cat=$cat&page=1"}
{php}
header( "Location: " . $GLOBALS[smarty]->_tpl_vars[prodURL] );
{/php}
{/if}
{/if}
|
|
#3
IP: 192.240.127.74
|
|||
|
|||
|
Just a note, if your using CDSEO then:
Replace: Code:
{assign var="prodURL" value="product.php?productid=`$products.0.productid`&cat=$cat&page=1"}
Code:
{assign var="prodURL" value="`$http_location`/`$cdseo_prod`/`$products.0.cdseo_url`"}
|
![]() |
| Currently Active Users Viewing This Thread: 3 (0 members and 3 guests) | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| .htaccess 301 Redirect | Packard | 建站交流 | 1 | 2014-06-15 07:53 PM |
| htaccess 301 redirect tutorial | yahoo | 服务器环境搭建 | 0 | 2009-09-06 12:45 AM |
| Becoming an editor at the Open Directory | yahoo | 闲话灌水 | 0 | 2009-05-24 01:08 PM |
| What are the Strongest Directories? | smiling | 网站链接开发 | 1 | 2007-07-28 09:26 PM |
| Building for the user and the bot. | admin | 建站交流 | 0 | 2006-01-17 03:54 PM |