X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   V4 - keeping first level subcategories viewable at all times (https://forum.x-cart.com/showthread.php?t=8755)

Sonia 02-25-2005 09:40 AM

Yes, I'm still at it...and am feeling stupid with this Smarty code.

I added this code to home.tpl

Code:

{if $smarty.get.cat eq "248"}
{include file="menu_blah.tpl"}
{elseif $categories ne "" and ($active_modules.Fancy_Categories ne "" or $config.General.root_categories eq "Y" or $subcategories ne "")}
{ include file="customer/categories.tpl" }


The file "menu_blah.tpl" is the custom menu I want to show in all the pages of a certain category. The problem is that menu only shows on one page, not the rest of it's category. I'm sure the code I need to change is : {$smarty.get.cat eq "248"}, but to what?

I'm still trying to control the order of the menu being shown at any given time. Like the control freak I am... :roll:

Thanks in advance...

fernando 02-25-2005 09:55 AM

I'm not sure what's in $smarty.get.cat. Would it be the current category that you're browsing?

In my code, I figure out what the (topmost) category we're browsing is by:

Code:

{assign var=current_category_top value=$current_category.categoryid_path|regex_replace:"/\/.*/":""}

So that variable current_category_top will hold the topmost category in the current category tree.

So if you're browsing

Food :: Chinese :: Noodles :: Very thin ACME noodles

current_category_top will report "Food". Would this do the trick for you?

This is all trial and error... but I'd suggest you'd try this:

Code:

{assign var=current_category_top value=$current_category.categoryid_path|regex_replace:"/\/.*/":""}
{if $current_category_top eq "248"}
{include file="menu_blah.tpl"}
{elseif $categories ne "" and ($active_modules.Fancy_Categories ne "" or $config.General.root_categories eq "Y" or $subcategories ne "")}
{ include file="customer/categories.tpl" }


Sonia 02-25-2005 10:30 AM

Fernando, you're a genius. That worked perfectly. It's a bit manual, but it's really only me that makes changes to this sort of thing, so that's okay.

Brilliant! I can move onto all the other annoying details...

Have a good one!

fernando 02-25-2005 10:39 AM

Amazing how I can't ever get it right the first time around when I work for my own store! Haha!

Glad I could be of help.

balinor 03-15-2005 10:34 AM

Quote:

1: modify categories.php so that the allcategories array is sorted by position (or probably better, create a sorted allcategories array clon and working with it from the .tpl)

Been messing with categories.php, and I have manged to get the sub-cats to be nicely ordered by position in the admin area, but no such luck on the customer side. Here's what I have in categories.php:

Code:

                if ($flag == "all")
                        $sort_condition = " ORDER BY $sql_tbl[categories].order_by";
                else
                        $sort_condition = " ORDER BY $sql_tbl[categories].order_by";
        }
        elseif (defined('MANAGE_CATEGORIES'))
                $sort_condition = " ORDER BY $sql_tbl[categories].order_by";


Any other place I should be adding an order_by??? Thanks in advance!

gabriela 03-17-2005 12:04 PM

I commented out
Code:

usort($all_categories, "func_categories_sort");
around line 154 and works for me.

balinor 03-17-2005 02:11 PM

Beautiful, thanks! :D

Jerrad 03-20-2005 03:50 PM

I'm trying to implement the code from zilker (thanks, btw :D), and till now I manage to display the categories horizontal in the head and to show the subcategories in the left menu, when a categorie is clicked.
So far so good...

But after clicking on a subcategorie the whole box with subcategories disappears. Like zilker I would like the box with subcategories to stay visible so a customer can choose another subcategorie without having to click again on the categorie.
I've tried to use the code provided by shan, but without any luck... :cry:

Could someone please be so kind to show how to do this?
Many thanks in advance!

Hyperdelicious 04-11-2005 10:34 AM

show sub categories only when main category is selected
 
This mod works great in 4.0.13 by combining heads Fernando and Gabriela provide X-er's with code that will list sub categories under the main category

Example:

MAIN NAV 1
MAIN NAV 2
sub nav 1
sub nav 2
sub nav 3
sub nav 4
MAIN NAV 3
MAIN NAV 4

Just add Fernando's code to customer/main/subcategories.tpl and to ensure categories maintain their 'order by' status take Gabriela's advice editing out 'usort' item within the includes/categories.php.

One other thing I hadn't found mentioned here... you must have "Always show Root Categories' checked in the admin section under general settings.

Thanks.

Jerrad 04-12-2005 02:59 PM

I've got it also working, but I'm looking for a solution to display all levels
of subcategories.
Not in a permanent way but only when a first level subcategorie is clicked.
The link below shows roughly what I'm looking for.

http://www.udm4.com/demos/expanding-multiple.php


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

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