网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > X-Cart
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 192.240.127.74
Old 2016-02-14, 07:40 PM
Pace Pace is offline
初级会员
 
Join Date: 2009-09-18
Posts: 1
Pace 现在声名狼藉
Default Redirect to Product Page when only One product in category

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}
Reply With Quote
  #2   IP: 192.240.127.74
Old 2016-02-14, 07:41 PM
Raelyn Raelyn is offline
初级会员
 
Join Date: 2006-01-02
Posts: 1
Raelyn 现在声名狼藉
Default

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}
Reply With Quote
  #3   IP: 192.240.127.74
Old 2016-02-14, 07:44 PM
Taberville Taberville is offline
初级会员
 
Join Date: 2012-07-10
Posts: 1
Taberville 现在声名狼藉
Default

Just a note, if your using CDSEO then:
Replace:
Code:
{assign var="prodURL" value="product.php?productid=`$products.0.productid`&cat=$cat&page=1"}
with:
Code:
{assign var="prodURL" value="`$http_location`/`$cdseo_prod`/`$products.0.cdseo_url`"}
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:45 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.