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

Link to parent/root cat

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 01-21-2010, 03:39 PM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Link to parent/root cat

Hey guys, I know I've seen this somewhere before, but I can't find it, and can't remember how I did this. I have a couple of clients that need links directly to a products root category, and a sub-categories parent category. Any idea what the context would be for this? I tried playing with the location variable with no success. Thanks!
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #2  
Old 01-22-2010, 08:46 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Link to parent/root cat

To link to a products root category based on the location variable you can...

Open product.php

FIND:

Code:
$smarty->assign("product",$product_info);

BEFORE ADD:

Code:
// WCM - Assign Root Category $product_info['root_category'] = $location[1][0]; $product_info['root_category_link'] = $location[1][1]; // / WCM - Assign Root Category

In skin1/customer/main/product.tpl use:

Code:
{if $product.root_category_link} <strong>Root Category:</strong> <a href="{$product.root_category_link}" title="{$product.root_category}">{$product.root_category}</a> {/if}
Reply With Quote
  #3  
Old 01-22-2010, 08:50 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Link to parent/root cat

Sweet - that looks like it will work exactly the way I want! Thanks Jon! Any ideas on the parent cat for a sub-cat?
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #4  
Old 01-22-2010, 09:10 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Link to parent/root cat

To show the parent of a subcategory:

Open home.php

FIND:

Code:
require $xcart_dir."/include/categories.php";


AFTER ADD:

Code:
// WCM - Get Parent Cat (customization) $wcmParentCat = func_query_first("SELECT categoryid,category FROM $sql_tbl[categories] WHERE categoryid='" . (int)$current_category['parentid'] . "'"); $current_category['parent_categoryid'] = $wcmParentCat['categoryid']; $current_category['parent_category'] = $wcmParentCat['category']; $smarty->assign('current_category',$current_category); // WCM - Get Parent Cat (customization)


In your template use:

Code:
{if $current_category.parent_categoryid gt 0} The parent category for this is: <a href="home.php?cat={$current_category.parent_categoryid}">{$current_category.parent_category}</a>. {/if}
Reply With Quote
  #5  
Old 01-22-2010, 10:10 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Link to parent/root cat

Beautiful! Thanks a million Jon. Only tweak necessary was to change this:

<a href="home.php?cat={$current_category.parent_categ ory}">

to this:

<a href="home.php?cat={$current_category.parent_categ oryid}">

Going to put this in the Custom Mods forum. FYI, this was tested on a 4.1.12 install.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #6  
Old 01-22-2010, 10:14 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Link to parent/root cat

Oops - thanks I've updated the instructions.

It will work on all versions 4.0-4.3. Versions prior to that didn't use the categoryid_path.
Reply With Quote
  #7  
Old 02-16-2010, 11:26 AM
 
dgallek dgallek is offline
 

Member
  
Join Date: Mar 2007
Posts: 10
 

Default Re: Link to parent/root cat

is there anyway to see this in action? I'm not sure I follow the description of the functionality and it sounds like something one of my clients want.

I'm using X-Cart 4.3
__________________
X-Cart v4.1.6
Reply With Quote
  #8  
Old 02-16-2010, 03:59 PM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Link to parent/root cat

It is just a simple link that links the user back to the product's root category.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #9  
Old 08-03-2010, 07:13 AM
 
chrischall chrischall is offline
 

Advanced Member
  
Join Date: Jul 2005
Posts: 36
 

Default Re: Link to parent/root cat

Hi Jon,

Im using 4.0.14 and the root category mod worked great thanks! However just tried the parent category part and that doesnt seem to show up - is there different coding for this version?

Cheers,
Chris
__________________
X-Cart version 4.6.3
Reply With Quote
  #10  
Old 12-01-2010, 08:46 AM
 
jvolvovski jvolvovski is offline
 

Advanced Member
  
Join Date: Nov 2007
Posts: 46
 

Default Re: Link to parent/root cat

I'm trying to check for a parent category in product.tpl in version 4.4.1

Any idea how I would do that?
None of the code above seems to match with the new version of x-cart.

Thanks!
Jenny
__________________
Version 4.3.2
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 08:05 PM.

   

 
X-Cart forums © 2001-2020