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)
-   -   root cat (https://forum.x-cart.com/showthread.php?t=50387)

ARW VISIONS 10-26-2009 12:58 PM

root cat
 
is there root cat syntax?

like

{if root_cat eq 255}

blah blah blah

{/if}

Ash

pauldodman 10-26-2009 01:06 PM

Re: root cat
 
if $cat eq "1" or $current_category.parentid eq "1"

ARW VISIONS 10-26-2009 01:10 PM

Re: root cat
 
but what if the are ina sub sub sub cat... you know 4 levels down?

ARW VISIONS 10-26-2009 01:13 PM

Re: root cat
 
paul,

didn't work at all. nothing showed.

cflsystems 10-26-2009 05:30 PM

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

ARW VISIONS 10-28-2009 06:52 AM

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

cflsystems 10-28-2009 08:09 AM

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());


ARW VISIONS 10-28-2009 08:48 AM

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

cflsystems 10-28-2009 09:00 AM

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

ARW VISIONS 10-28-2009 09:14 AM

Re: root cat
 
ok thanks, will try that.

Ash

ChristineP 10-29-2009 05:19 AM

Re: root cat
 
Ashley, I've tried using the root category in my products.tpl and with our flyout categories mod, but no cigar. I ended up creating other templates to get the result that I wanted, but it was far more work. If you find an answer for capturing the root category, please post it.

TBone 11-25-2009 05:33 AM

Re: root cat
 
Try this:

{$current_category.categoryid_path|regex_replace:" /\/[0-9\/]*/":""}

this fetches the root category from the path. It finds the first "/" and replaces everything after it with nothing leaving the current root cat id.

Hope this helps.

hollaratbear 11-27-2009 07:38 PM

Re: root cat
 
Has anybody gotten any of these to work? I've been looking to implement this as well. I tried a few suggestions here but no dice......

ARW VISIONS 11-27-2009 07:50 PM

Re: root cat
 
nope never got it to work.

Jon 01-22-2010 08:18 AM

Re: root cat
 
I always like keeping processing in php when possible.

Open home.php

FIND:

Code:

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

AFTER ADD:

Code:

// WCM - Get Root Cat (customization)
$wcmRootCat = func_query_first("SELECT categoryid,category FROM $sql_tbl[categories] WHERE categoryid='" . (int)current(explode('/',($current_category['categoryid_path']))) . "'");
$current_category['root_categoryid'] = $wcmRootCat['categoryid'];
$current_category['root_category'] = $wcmRootCat['category'];
$smarty->assign('current_category',$current_category);
// / WCM - Get Root Cat (customization)


In your template use:

Code:

{if $current_category.root_categoryid eq X}
    The root category for this is: {$current_category.root_category}.
{else}
Something else
{/if}


Jon 01-22-2010 08:27 AM

Re: root cat
 
Just reviewed the reason behind needing this and our Category Map module be be a solution: http://www.websitecm.com/x-cart-mods/x-cart-seo-category-map.html

Duramax 6.6L 01-23-2010 12:45 PM

Re: root cat
 
Could someone please explain in detail why this is so important.

Jon 01-23-2010 06:54 PM

Re: root cat
 
Why what in particular is so important?


All times are GMT -8. The time now is 07:41 PM.

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