Transfer parent title variable of active menu item |
|
Doug Evans
|
<div>Thanks to all of you I have been able to create a variable: $mytitle from the active parent menu item in Joomla 3.<br />
<br />
This is my code:<br />
<br />
<div><strong>Code:</strong></div>
<div>$menu = JFactory::getApplication()->getMenu();<br />
$parent = $menu->getItem( $menu->getActive()->parent_id );<br />
$parentname = $parent->title;<br />
$parentlink = JRoute::_( $parent->link . '&Itemid=' . $parent->id );<br />
$menulevel = $menu->getActive()->level; $activename= $menu->getActive()->title; <br />
$mytitle = ($menulevel == 1)?$activename:$parentname;<br />
echo $mytitle;</div>
<br />
<br />
This works great but now I need to use it on my submenu item (VMenuBlock). The code is as follows and I cannot seem to figure out how to place the variable so that it works?<br />
<br />
<div><strong>Code:</strong></div>
<div>function modChrome_vmenu($module, &$params, &$attribs)<br />
{<br />
if (!empty ($module->content)) {<br />
if (function_exists('VMenuBlock'))<br />
echo VMenuBlock(($module->showtitle != 0) ? $module->title : '', $module->content,<br />
$params->get('moduleclass_sfx'));<br />
else<br />
echo Block(($module->showtitle != 0) ? $module->title : '', $module->content,<br />
$params->get('moduleclass_sfx'));<br />
}<br />
}</div>
<br />
<br />
Any help or suggestions is appreciated!, Thanks! Doug</div>
|
|
Doug Evans
|
Sorry, it looked fine when I posted it![
quote=Doug Evans]
Thanks to your support I have been able to create a variable: $mytitle from the active parent menu item in Joomla 3.
This is my code:
Code:
$menu = JFactory::getApplication()->getMenu();
$parent = $menu->getItem( $menu->getActive()->parent_id );
$parentname = $parent->title;
$parentlink = JRoute::_( $parent->link .
'&Itemid=' .
$parent->id );
$menulevel = $menu->getActive()->level; $activename= $menu->getActive()->title;
$mytitle = ($menulevel == 1)?$activename:$parentname;
echo $mytitle;
This works great but now I need to use it on my submenu item (VMenuBlock).
The code is as follows and I cannot seem to figure out how to place the variable so that it works?
Code:
function modChrome_artvmenu($module, &$params, &$attribs)
{
if (!empty ($module->content)) {
if (function_exists('artxVMenuBlock'))
echo artxVMenuBlock(($module->showtitle != 0) ? $module->title : '', $module->content,
$params->get('moduleclass_sfx'));
else
echo artxBlock(($module->showtitle != 0) ? $module->title : '', $module->content,
$params->get('moduleclass_sfx'));
}
}
Any help or suggestions is appreciated!, Thanks! Doug
|
|
|
|