Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Link to Main Category from Product Page

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-25-2009, 06:22 AM
 
theUKdude theUKdude is offline
 

Member
  
Join Date: Jun 2006
Posts: 16
 

Default Link to Main Category from Product Page

Hi,

I would like to place a link on each product page which would take the customer to the main category of that particular product. Similar to the breadcrumbs, but only to the product's main category, regardless of any subcategory or additional category it might be in.

I'm hoping this is possible ... any help would be very much appreciated.

Many thanks,
__________________
theUKdude

X-Cart Gold - 4.1.9
Apache 2.2.10
MySQL 5.0.67
PHP 5.2.9
Reply With Quote
  #2  
Old 03-25-2009, 06:52 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Link to Main Category from Product Page

skin1/customer/main/product.tpl

Button...
Code:
{include file="buttons/button.tpl" style="button" button_title="Back to Product Category" href="home.php?cat=`$current_category.parentid`"}
or hyperlink...
Code:
<a href="home.php?cat={$current_category.parentid}">Back to Product Category</a>
Or you can change 'parentid' to just 'categoryid'.
__________________
xcartmods.co.uk
Reply With Quote
  #3  
Old 03-25-2009, 08:08 AM
 
theUKdude theUKdude is offline
 

Member
  
Join Date: Jun 2006
Posts: 16
 

Thumbs up Re: Link to Main Category from Product Page

ooooo, this is so close to what I need!

Is there no way to specify the actual 'Main Category' the product is listed in? I ask because I have categories set out this way:

> Brands
>> Brand 1
>> Brand 2
>> Brand 3
> Category A
> Category B
> Category C

Now the 'main category' for each product is either Brand 1, Brand 2 or Brand 3, let's say Product X's main category is Brand 2 ... and Product X is also in multiple 'additional' categories, such as Category A and Category C. When the customer views Product X by navigating through Category C, I would like a link on that product which would take the customer back to Product X's main category ... in this case Brand 2 ... so they can view all other products in that main category i.e. of the same brand. You follow me?

I may be over complicating that example ... so I apologise, hehe.

So is there a variable like $main_category.id maybe? There must be a way of grabbing each products main category variable?

Thanks for your help though ... it's brought me closer!
__________________
theUKdude

X-Cart Gold - 4.1.9
Apache 2.2.10
MySQL 5.0.67
PHP 5.2.9
Reply With Quote
  #4  
Old 03-25-2009, 09:38 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Link to Main Category from Product Page

Yes, as I said, just change 'parentid' to 'categoryid'
__________________
xcartmods.co.uk
Reply With Quote
  #5  
Old 03-26-2009, 03:12 AM
 
theUKdude theUKdude is offline
 

Member
  
Join Date: Jun 2006
Posts: 16
 

Default Re: Link to Main Category from Product Page

Thanks PhilJ,

I've tried this though, and it links back to the current category instead of the main category, as the variable suggests.

So if the 'Main Category' of Product X is 'Brand 2' but the customer navigates to Product X via the additional category 'Category C', the link will return them to Category C instead of Brand 2.

Is there a variable for the Main Category? There must be, surely?

Thanks for your help Phil
__________________
theUKdude

X-Cart Gold - 4.1.9
Apache 2.2.10
MySQL 5.0.67
PHP 5.2.9
Reply With Quote
  #6  
Old 07-09-2009, 07:57 AM
 
autobulbs autobulbs is offline
 

Advanced Member
  
Join Date: Feb 2007
Location: Southampton, UK
Posts: 68
 

Default Re: Link to Main Category from Product Page

<a href="{$location[1][1]}">{$location[1][0]}</a>
__________________
Autobulbs Direct Ltd
X-Cart Version: 4.2.2
eWay Designs - Custom X-Cart Templates / CMS Websites / Bespoke web applications
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:24 AM.

   

 
X-Cart forums © 2001-2020