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

root cat

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-26-2009, 12:58 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default root cat

is there root cat syntax?

like

{if root_cat eq 255}

blah blah blah

{/if}

Ash
__________________
xcart 5.1.2
Reply With Quote
  #2  
Old 10-26-2009, 01:06 PM
  pauldodman's Avatar 
pauldodman pauldodman is offline
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,062
 

Default Re: root cat

if $cat eq "1" or $current_category.parentid eq "1"
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote

The following user thanks pauldodman for this useful post:
Ashley (10-28-2009)
  #3  
Old 10-26-2009, 01:10 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: root cat

but what if the are ina sub sub sub cat... you know 4 levels down?
__________________
xcart 5.1.2
Reply With Quote
  #4  
Old 10-26-2009, 01:13 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: root cat

paul,

didn't work at all. nothing showed.
__________________
xcart 5.1.2
Reply With Quote
  #5  
Old 10-26-2009, 05:30 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: root cat

$cat is the current category id
$current_category.parentid is one level up obviously (which will work if you have only one level down)
There is also $current_category.categoryid_path which first element will be the first category id for the sub sub sub cat. It is in the form of 123/234/345...
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
Ashley (10-28-2009)
  #6  
Old 10-28-2009, 06:52 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: root cat

how do you do a foreach from a certain category only?

like say list sub one level down just from cat 255
__________________
xcart 5.1.2
Reply With Quote
  #7  
Old 10-28-2009, 08:09 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: root cat

How about this

<ul>
{foreach from=$allsubcategories item=c}
{if $c.parentid eq "255"}
<li>$c.category</li>
{/if}
{/foreach}
</ul>

If you don't have $allsubcategories this is how to get them (I can't remember the thread)

add to /include/categories.php at the end before subcategories and cat assigns
Code:
function func_getallsubcat() { $raj = func_get_categories_list("",true,"all"); $raj1 = $raj['all_categories']; $ll = array(); foreach ($raj1 as $k=>$val) { if($val['parentid']!="0") { $ll[$val['parentid']][]=$val; } } return $ll; } $smarty->assign("allsubcategories",func_getallsubcat());
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
Ashley (10-28-2009)
  #8  
Old 10-28-2009, 08:48 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: root cat

couldn't figure it out, so I hard coded it.

Here the whole scenario.

There are 10 root cats all together. 5 of them have a sub cat that list gemstone cats

so

rings > gemstone rings > Amethyst, Pearl, Emerald, Garnet Ruby ect...

earrings > gemstone earrings> Amethyst, Pearl, Emerald, Garnet Ruby ect...

I want to list the sub cats of the gemstone rings on the rings root cat page

and

I want to list the sub cats of the gemstone earrings on the earrings root cat page
__________________
xcart 5.1.2
Reply With Quote
  #9  
Old 10-28-2009, 09:00 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: root cat

Ok try in subcategories template used to show subcats

<ul>
{if $cat eq "rings"}
{foreach from=$allsubcategories item=c}
{if $c.parentid eq "gemstone rings"}
<li>$c.category</li>
{/if}
{/foreach}
{elseif $cat eq "earrings"}
{foreach from=$allsubcategories item=c}
{if $c.parentid eq "gemstone earrings"}
<li>$c.category</li>
{/if}
{/foreach}
{/if}
</ul>

Replace cat names with cat numbers
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
Ashley (10-28-2009)
  #10  
Old 10-28-2009, 09:14 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: root cat

ok thanks, will try that.

Ash
__________________
xcart 5.1.2
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 07:53 PM.

   

 
X-Cart forums © 2001-2020