Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / xpanded category tree for drop down menu

xpanded category tree for drop down menu

Views: 10,600

Results 41 to 54 of 54
13 Feb 2012, 6:14 PM
#41
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

xpanded category tree for drop down menu

That would be one of the parameters you use when calling the function.

str_replace_int($needle, $repl, $haystack, $interval, $first=1, $pos=0)

str_replace_int($needle, $repl, $haystack, 7, 8)

to add the class to every seventh <li> starting with the eighth (you don't want it on the first).

13 Feb 2012, 8:02 PM
#42
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: xpanded category tree for drop down menu

maybe id be better explaining what im trying to do, i have installed this module onto a test site, i have 2 categories with lots of subs and rather than the subs going away off page id like to split it onto a new row if thats possible, so accessories may take 2 columns or three if required,

http://catchagrip.co.uk/megamenu/

thanks
Bryan

18 Feb 2012, 12:36 AM
#43
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: xpanded category tree for drop down menu

Is that site firewalled?

20 Feb 2012, 12:24 AM
#44
thomasipi avatar

thomasipi

New Zenner

Join Date:
Oct 2011
Posts:
3
Plugin Contributions:
0

Re: xpanded category tree for drop down menu

Great mod, I am however having the problem with the hanging rows.

I've downloaded the Replace String mod and have read the readme and FTP'd the php file but can't seem to get it working (I have very limited PHP experience). I need to add a clear:left to every 4th top level category <li>.

Any help would be appreciated!

20 Feb 2012, 4:28 AM
#45
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: xpanded category tree for drop down menu

Bryan - You have so many subcategories that I don't see any good way to display them all on one mega-menu - they more than fill my 23" widescreen monitor as is. You would need to have a breakdown by top categories or groups of them to be able to show all of their subcats in an average monitor (scrolling is not possible with the mega-menu).

20 Feb 2012, 4:32 AM
#46
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: xpanded category tree for drop down menu

thomasipi - I haven't recently looked at the code of the mega-menu mod version to be able to say without some study exactly where you should put the str_replace_int() function call. I have other obligations currently, but will try to check on it when I get time.

Your replacement would not be to add clear: left; directly, but to add a class tag to the <li> which you would style in your stylesheet as clear: left;.

20 Feb 2012, 6:17 AM
#47
thomasipi avatar

thomasipi

New Zenner

Join Date:
Oct 2011
Posts:
3
Plugin Contributions:
0

Re: xpanded category tree for drop down menu

Thanks for the response.

Makes sense that the clear:left would be defined in the css.

I assume the code will have to be inserted somewhere in the below section of tpl_drop_menu.php, I'm just not entirely sure how to correctly call the function to add a new class every 4 list items.

require_once (DIR_WS_CLASSES . 'categories_ul_generator.php');
$zen_CategoriesUL = new zen_categories_ul_generator;
$menulist = $zen_CategoriesUL->buildTree(true);
$menulist = str_replace('"level4"','"level5"',$menulist);
$menulist = str_replace('"level3"','"level4"',$menulist);
$menulist = str_replace('"level2"','"level3"',$menulist);
$menulist = str_replace('"level1"','"level2"',$menulist);
$menulist = str_replace('<li class="submenu">','<li class="submenu">',$menulist);
$menulist = str_replace("</li>\n</ul>\n</li>\n</ul>\n","</li>\n</ul>\n",$menulist);
echo $menulist;

Would be greatly appreciated if you could look at this when you have the time.

Thanks.

20 Feb 2012, 7:25 AM
#48
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: xpanded category tree for drop down menu

Probably like this:```php
$menulist = str_replace('<li class="submenu">','<li class="submenu">',$menulist);
$menulist = str_replace_int('<li class="submenu">','<li class="submenu clearBoth">',$menulist, 4, 5);//new line for clean wrapping


to add the class to every fourth <li> starting with the fifth (you don't want it on the first). 
Add to your stylesheet
 .clearBoth {clear: both;}
if it is not already there (I forget if the ZC stock <br class="clearBoth" />  uses just the class tag in its rule).
20 Feb 2012, 7:30 AM
#49
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: xpanded category tree for drop down menu

Note that this might have undesired effects if the replacement happens for top level submenus as well as subcategory menus, depending on exactly how you have the overall menu laid out.

22 Feb 2012, 11:25 PM
#50
thomasipi avatar

thomasipi

New Zenner

Join Date:
Oct 2011
Posts:
3
Plugin Contributions:
0

Re: xpanded category tree for drop down menu

Thank you very much, that did the trick!

23 Feb 2012, 10:16 PM
#51
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: xpanded category tree for drop down menu

thanks gjh42 for reply, yes loads of subs, is it possible to have main categories along top and only subs of that category as you hover, at least only showing subcategories of 1 category at a time, i do seem to be making progress but still a lot of subs on one menu

http://www.catchagrip.co.uk/megamenu/

bn

24 Feb 2012, 6:48 AM
#52
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: xpanded category tree for drop down menu

The point of a "megamenu" is to show everything at once; if you don't want that, you might best go back to the regular dropdown menu which shows only the subs in the current active tree. It sounds like you may be talking about something in between, which will be more complex to implement than either extreme.

25 Feb 2012, 8:50 AM
#53
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: xpanded category tree for drop down menu

yes i have ordinary drop down menu on my site at the minute but when you go to parts or accessories the list of subs goes away off page, so thought i could use megamenu to make them go in columns accross page,

this maybe isnt now the right place to ask but am starting to go in right direction if you take another look

http://catchagrip.co.uk/megamenu/

so i have added another file called zen_categories_ul_generator_accessories.php in classes and limited it to only show c.categories_id=445 or c.parent_id=445

 $categories_query = "select c.categories_id, cd.categories_name, c.parent_id
										from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
										where c.categories_id = cd.categories_id
										and c.categories_status=1 and c.categories_id=445 or c.parent_id=445" .
        								" and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
        								" order by c.parent_id, c.sort_order, cd.categories_name";

and it seems like it is going to do my job but it calls every sub category workstand but the link is correct, any idea what im doing wrong

thanks
Bryan

25 Feb 2012, 9:16 AM
#54
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: xpanded category tree for drop down menu

a step closer

changed to

$categories_query = "select c.categories_id, cd.categories_name, c.parent_id
										from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
										where c.categories_status=1 and c.categories_id='1' or c.parent_id='1'
										and c.categories_id = cd.categories_id" .
        								" and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
        								" order by c.parent_id, c.sort_order, cd.categories_name";