Page 1 of 1
Passing Dynamic Values to Modules? (MenuManager)
Posted: Wed Jul 26, 2006 5:43 pm
by mkuehn
Helllo, I'm realtively new to CMSMS, so please bear with me.
I want MenuManager only to display the children of the current section. I can do this manually in my template by specifying the start_page like so:
{cms_module module='menumanager' collapse='1' start_page='living_here'}
That does exactly what I want, but seeing as that module call is in the template, it always shows the "living_here" section's navigation, regardless of the section I'm actually viewing.
Is there a way to do something like this in the template:
{cms_module module='menumanager' collapse='1' start_page='{current_section}'}
so that the current section is dynamically passed to MenuManager from the template? Is there already a list of global variables that can be used this way?
Or is this a change that would need to be made in the code for the MenuManager itself? Perhaps using a $node value?
I appreciate your help.
Thanks,
Matthew
Re: Passing Dynamic Values to Modules? (MenuManager)
Posted: Wed Jul 26, 2006 5:46 pm
by tsw
Have you tried parameter start_level="2"
Re: Passing Dynamic Values to Modules? (MenuManager)
Posted: Wed Jul 26, 2006 6:01 pm
by mkuehn
No, I hadn't, but that's exactly what I needed; thank you.
I had read the help for MenuManager, and now that I've gone back and read through it a couple of times, the description of start_level make sense. It didn't, however, initially, which is why I had to ask.
Still unclear to me is how would passing a 3 as start_level affect the menu? Does "3" even exist? How about 4, 5...? Or, how does that value I pass relate to the hierarchy I've established in Content >> Pages?
Also, is it possible to pass dynamic values into modules, like I asked in the opening post, or does the code in the module called have to look at variable values? Is there a list of {variable} variables that are common to CMSMS?
Thanks again,
Matthew
Re: Passing Dynamic Values to Modules? (MenuManager)
Posted: Wed Jul 26, 2006 6:24 pm
by tsw
Great that it works
start_level depends on your page hierarchy
e.g you have page hierarchy like
- frontpage (level 1)
- - frontapge children (this is level 2)
- - - frontpage grandchild (this is level 3)
- secondpage (again level 1)
some variables can be used in module calls. it depends on how the variable is created.
For example {sitename} is also $sitename and so can be used for module calls like {somemodule param1=$sitename}
and you can create new variables out of any content with smarty capture.
if I remember syntax correctly its something like
{capture name="variablename"} anythin here including {calls to other modules}{/capture}
now $variablename will contain everything that was between {capture} and {/capture}. This method is not bulletproof and might be slow.
hope this helps
Re: Passing Dynamic Values to Modules? (MenuManager)
Posted: Wed Jul 26, 2006 6:44 pm
by Elijah Lofgren
mkuehn wrote:
Is there a way to do something like this in the template:
{cms_module module='menumanager' collapse='1' start_page='{current_section}'}
so that the current section is dynamically passed to MenuManager from the template? Is there already a list of global variables that can be used this way?
Create a new User Defined Tag named "page_alias" with the following content:
Code: Select all
global $gCms;
$gCms->smarty->assign('page_alias', $gCms->variables['page_name']);
Then call your menu like this (note the double quotes instead of single quotes around "$page_alias":
Code: Select all
{page_alias}
{cms_module module='menumanager' collapse='1' start_page="$page_alias"}
Check this page for more example Menu Manager Templates:
http://wiki.cmsmadesimple.org/index.php ... nu_Manager
Hope this helps,
Elijah