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)
-   -   Show menu based on category (https://forum.x-cart.com/showthread.php?t=48256)

mrerotic 06-24-2009 01:30 AM

Show menu based on category
 
How can I check if someone has selected a certain category or subcategory in a category? What I'm trying to do is basically make two different main category homepages. One for 'Product 1' and another for 'Product 2'.

If user clicks on the main category menu on the actual store welcome page for 'Product 1' then I dont want to show the main menu anymore I just want to show some menus that are relavant to this category instead. Same for 'Product 2'.

Is this possible? Anyone have a module?

Victor D 06-24-2009 06:34 AM

Re: Show menu based on category
 
copy customer/home.tpl to customer/home2.tpl

change your customer/home.tpl:
Code:

{if $main eq "catalog" && $current_category.categoryid eq "Custom_category_id"}
{include file="customer/home2.tpl"}

{else}
....Your current home.tpl content

{/if}

and edit home2.tpl
It will be displayed only for one custom category.

mrerotic 06-24-2009 11:06 PM

Re: Show menu based on category
 
Victor thanks - how can I limit a number of subcategories to be displayed under the main category for a menu? Say for instance I'm using what you provided me above for category_id = 1. How can I limit number of subcategories to '5' and if possible make them random? I know php, but smarty is kickin my a$$. Thanks

mrerotic 06-24-2009 11:23 PM

Re: Show menu based on category
 
Also how can I make sure that this new homepage appears for all subcategories under this main category?

Victor D 06-25-2009 12:26 AM

Re: Show menu based on category
 
Can you describe the result you want to achieve as I don't catch it

mrerotic 06-25-2009 12:41 AM

Re: Show menu based on category
 
What I'm trying to do is have a totally seperate area for a category and this area will be shown for all subcategories under this. Basically like another homepage for a cetain product with different menus and search options that relate to this category. Is this possible? THX Victor for your assistance.

Victor D 07-01-2009 07:10 AM

Re: Show menu based on category
 
add in your include/categories.php

right before the lines
Code:



#
# Gather the array of categories and extract into separated arrays:
# $all_categories, $categories and $subcategories
#


this code:
Code:

/*custom home.tpl mod*/
$_r_cat = 103; //this category and its offsprings will have custom home.tpl
$_path = explode('/', $current_category['categoryid_path']);
if (in_array($_r_cat, $_path)){
 $smarty->assign("area2", "true");
}
/*custom home.tpl mod ends*/



your customer/home.tpl should be like this:
Code:

{if $area2 ne ''}
{include file="customer/home2.tpl"}
{else}
....Your current home.tpl content
{/if}


mrerotic 07-02-2009 07:23 PM

Re: Show menu based on category
 
Victor thank you. When your using clean urls the (cat) number doesnt get passed at least that you can see. How can I pickup the category number when using clean urls for the categories to know which category id im in?

Thanks :)

Victor D 07-13-2009 01:11 AM

Re: Show menu based on category
 
Do you need to know current category id in templates or in php script?
For templates it is
Code:

{$current_category.categoryid}

mrerotic 09-06-2009 02:58 PM

Re: Show menu based on category
 
Ok issue im having. Is I added everything you said Victor. But what I want is right now Im showing a new menu that lists all subcategories for main category "DVDs" but once you click on one of those subcategories in the new menu all the subcategories disappear in this menu. How can I make these subcategories remain throughout this specific main category "DVDs" and subcategories? I just want a static menu for this section that shows all the subcategories all the time if they are in the main category "DVDs" section. I hopt his makes sense.


All times are GMT -8. The time now is 04:40 PM.

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