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)
-   -   Custom Category and Subcategory Menu Blocks (https://forum.x-cart.com/showthread.php?t=19040)

techdesign 01-04-2006 01:22 PM

Custom Category and Subcategory Menu Blocks
 
I am trying to create a custom menu block that displays depending on what the root category the user is browsing.

So far I have came up with a few ways to display the custom menu when they are in a specific category, but when they browse to a subcategory - the menu is gone.

Here are the different ways I have found so far, but again it only works for the current category that they are in:
Code:

{if $current_category.category eq "Livestock"}
{ include file="customer/menu_livestock.tpl" }
{/if}
{if $current_category.categoryid eq "2"}
{ include file="customer/menu_horse.tpl" }
{/if}
{if $cat eq "3"}
{ include file="customer/menu_pet.tpl" }
{/if}


How can I create something like this, but will work acrosss the subcategories of the specific root category?

Also there is only 3 root categories if that makes it simple...

balinor 01-04-2006 01:27 PM

Please post your X-Cart version in your signature per the forum rules.

techdesign 01-04-2006 01:30 PM

sorry, when I started using X-Cart it wasnt necessary. But its done now

balinor 01-04-2006 02:07 PM

I just did this for a client...let me dig up the code and post it for you.

techdesign 01-04-2006 02:49 PM

thanks!

techdesign 01-05-2006 04:41 PM

Where you able to dig it up? I really appreciate the help...

balinor 01-05-2006 05:12 PM

Still trying to find it....too many clients :)

balinor 01-06-2006 04:48 AM

Ok, here's the code you want:

Code:

{if $location[0].0 eq "Rootname"}
Custom menu display code
{/if}


Replace Rootname with the name of the root category you want it displayed for. If you have three root categories, all of which will show different menus, write it like this:


Code:

{if $location[0].0 eq "Rootname"}
Custom menu display code
{elseif $location[0].0 eq "Rootname2"}
Custom menu display code 2
{elseif $location[0].0 eq "Rootname3"}
Custom menu display code 3
{/if}


Hope this helps!

techdesign 01-06-2006 09:15 AM

I had tried something like this, but it doesn't seem to work. Not sure whats up. Any ideas?

Code:

{if $location[0].0 eq "Livestock"}
{ include file="customer/menu_livestock.tpl" }
{elseif $location[0].0 eq "Horse"}
{ include file="customer/menu_horse.tpl" }
{elseif $location[0].0 eq "Pet"}
{ include file="customer/menu_pet.tpl" }
{/if}


balinor 01-06-2006 09:25 AM

It must be something to do with Pro :( Try opening a ticket with X-Cart and see if they can assist....

techdesign 01-09-2006 09:07 AM

Well we were close. Here is what works:

Code:

{if $location[1].0 eq "Livestock" }
{ include file="customer/menu_livestock.tpl" }
{elseif $location[1].0 eq "Horse"}
{ include file="customer/menu_horse.tpl" }
{elseif $location[1].0 eq "Pet"}
{ include file="customer/menu_pet.tpl" }
{/if}



I am wanting to take it one step further and include certain pages also. For example:

Code:

{if $location[1].0 eq "Livestock" or $smarty.get.pageid eq '1'}
{ include file="customer/menu_livestock.tpl" }
...


Which works, but I want to add mutiple pages. Like pageid 1,3,4,6,7,8 for the first section and 9, 10, 13, 14, etc for second section and so on and so forth. I'm not sure how to add the multiple pages without having to do them each separate. Like this -

Code:

{if $location[1].0 eq "Livestock" or $smarty.get.pageid eq '1' or $smarty.get.pageid eq '3' or $smarty.get.pageid eq '4' or $smarty.get.pageid eq '6' ....

This would get fairly messy. I'm looking for something more like this -
Code:

{if $location[1].0 eq "Livestock" or $smarty.get.pageid eq '1,3,4,6,7,8'}
{ include file="customer/menu_livestock.tpl" }
...

But I don't have a clue how to get 'er done.

Ideas?

mudebate 02-06-2009 11:00 AM

Re: Custom Category and Subcategory Menu Blocks
 
Can this code be modified to work based on the root category id?

Just curious

mudebate 02-06-2009 12:09 PM

Re: Custom Category and Subcategory Menu Blocks
 
Also, let's say I want to display .tpl file only on the product page for a specific product. Could something like this be written that would do this?

Ie.
{if product id eq 1}
{include customer/abd.tpl}
{/if}

Thanks for the help!

mudebate 02-06-2009 01:18 PM

Re: Custom Category and Subcategory Menu Blocks
 
OK, figured it out:

{if $product.productid eq '47'}
{include file="yourfilename.tpl"}
{/if}


All times are GMT -8. The time now is 12:23 AM.

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