X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Link to Main Category from Product Page (https://forum.x-cart.com/showthread.php?t=46536)

theUKdude 03-25-2009 06:22 AM

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,

PhilJ 03-25-2009 06:52 AM

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'.

theUKdude 03-25-2009 08:08 AM

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!

PhilJ 03-25-2009 09:38 AM

Re: Link to Main Category from Product Page
 
Yes, as I said, just change 'parentid' to 'categoryid' :)

theUKdude 03-26-2009 03:12 AM

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

autobulbs 07-09-2009 07:57 AM

Re: Link to Main Category from Product Page
 
<a href="{$location[1][1]}">{$location[1][0]}</a>


All times are GMT -8. The time now is 09:40 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.