Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

One menu module used for 50 different menus?

One menu module used for 50 different menus?

I'm working on a site that has 50 menus, one for each USA state.  Each menu lists the major cities of that state; texas/dallas , texas/houston , etc.  These menus will show up in the "innerbottom" position of these pages.

I have the menus created, pages created, and now need to create the menu modules for each menu.  Instead of creating 50 different menu modules is it possible to use one menu module assigned to the "innerbottom" position for all of these menus and the one menu module is able to know which respective menu to pull from using MetaMod?

Thanks.

hominid4
Beginner Modder
ranks
useravatar
Offline
13 Posts
Administrator has disabled public posting

Re: One menu module used for 50 different menus?

Answer: yes!

The only question is how MetaMod is supposed to know which of the menus it is supposed to display. Do you want this to be based on the GeoIP location of the visitor, or based on which menu item the current page is on?

Irrespective of the "trigger" (or condition), you would use the technique described on http://www.metamodpro.com/metamod/contr … parameters to tell the included module which of the menus to display. It's probably the "menutype" parameter, so you might do something like this:

// some code here has to determine which menu to display, and put it
// into the variable $m. e.g. $m may be "texasmenu". Then we continue:
$menu_module = 111; // change this to the ID of the menu module you are using
$changes->mod($menu_module)->setParam("menutype",$m);
return $menu_module;


Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3319 Posts
User info in posts
Administrator has disabled public posting

Re: One menu module used for 50 different menus?

Hi, thanks a bunch. Sorry, I had searched around in the recipes and skipped right over that page.  Just what I need!

My Texas menu is "locationstexas", and for my testing I created a second menu named "locationsalabama".

I then created a Menu Module and selected the "locationstexas" menu; it has the module ID 104.

I then created a MetaMod module, and assigned it to the "innerbottom" position.  Within the PHP I put:

Code:

$menu_module = 104;

$changes->mod($menu_module)->setParam("menutype",$m);
return $menu_module;

This pulls the "locationstexas" but when viewing the "locationsalabama" menu items the "locationstexas" menu still shows.  I forgot to mention that I'm using Joomla 3, does that make a difference in the code?

Here are my test links:

http://www.absolutecolor.com/online-printer/texas.html

http://www.absolutecolor.com/online-pri … abama.html

Thanks again!

hominid4
Beginner Modder
ranks
useravatar
Offline
13 Posts
Administrator has disabled public posting

Re: One menu module used for 50 different menus?

Hi,

in order for the code that I posted to work, you already have to have put a line something like:

$m = "locationsalabama";

Then the rest of the code will use this to set the menu of the menu module to locationsalabama. If you just set it up like that it will demonstrate the principle of changing a module's parameter on the fly.

A deeper question, once you have that part working, is how are you going to determine what $m is in each case? In other words, under what circumstances do you want the Alabama menu to show instead of the Texas one? Is it based on what menu you are on already? Or GeoIP location? Or something else?

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3319 Posts
User info in posts
Administrator has disabled public posting

Re: One menu module used for 50 different menus?

Oh sorry, forgot to answer your question on that; yes the menu to be shown is based on what menu you are on, the menutype.  Not GeoIP.

My adjusted code is:

$m = "locationstexas";
$menu_module = 104;
$changes->mod($menu_module)->setParam("menutype",$m);
return $menu_module;

http://www.absolutecolor.com/online-pri … abama.html

Thanks!

hominid4
Beginner Modder
ranks
useravatar
Offline
13 Posts
Administrator has disabled public posting

Re: One menu module used for 50 different menus?

Ok, so basically it looks like you want to propagate the current menu type: if you're already on "locationstexas" then you want to show that menu module, right?

Luckily there's a super easy way to get this information, built in to MetaMod.

$m = $menu_genius->info( "menutype" ); // this gets the current menutype
$menu_module = 104;
$changes->mod($menu_module)->setParam("menutype",$m);
return $menu_module;


So what this does is retrieves the current menu that you are on, whatever it is, and feeds that to the menu module that it's about to display.

The only issue with this is that it's possible that you have other menus on your system that are NOT the 50 states (perhaps a "top" menu or "admin" or something like that). In that case, if the person is viewing a page in that menu, then *that's* the menu that will appear in the innerbottom position.

So you might want to exclude certain menus from triggering this, like this:

$m = $menu_genius->info( "menutype" ); // this gets the current menutype
if ($m == 'topmenu' or $m == 'mainmenu' or $m == 'someothermenu') return; // short-circuit if it's one of the ones you don't want
// otherwise, set the menu to the current one:
$menu_module = 104;
$changes->mod($menu_module)->setParam("menutype",$m);
return $menu_module;

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3319 Posts
User info in posts
Administrator has disabled public posting

Re: One menu module used for 50 different menus?

Beautiful, that worked perfectly!  I'll assign the MetaMod module to only those 50 states so we should be good but I'll watch out for any conflicts with other menus.

Thank you for your time!,
Wesley

hominid4
Beginner Modder
ranks
useravatar
Offline
13 Posts
Administrator has disabled public posting

Re: One menu module used for 50 different menus?

Yeah, that sounds like a good way to restrict what it's going to show - should be foolproof I think!

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3319 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1675
Total Polls:
6
Total Posts:
5917
Posts this week:
6
User Info:
 
Total Users:
11584
Newest User:
allen6221
Members Online:
0
Guests Online:
159

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked