I just tried this and it did not work for me (Joomla is stripping out my code)
Instead, I added this to modules/mod_mainmenu.xml
Code: Select all
<param name="link_sfx" type="text" default="" label="Link Suffix" description="PARAMMODULELINKSUFFIX" />
I set my module class suffix to "modal"
and added this to my new link suffix parameter
Code: Select all
class="modal" rel="{handler: 'iframe', size: {x: 720, y: 630}}"
Then, I alter the output to include the link by using a mod_mainmenu output override in templates/templatename/mod_mainmenu/default.php as follows:
Code: Select all
<?php // no direct access
defined('_JEXEC') or die('Restricted access');
if ( ! defined('roundedCornerPatch') )
{
function roundedCornerPatch($result,$params){
$result = str_replace("<a href=","<a " . $params->get('link_sfx') . " href=",$result);
return $result;
}
define('roundedCornerPatch', true);
}//This is copied from mod_mainmenu and renamed to 'modMyMainMenuXMLCallbackDefined'
if ( ! defined('modMyMainMenuXMLCallbackDefined') )
{
function modMyMainMenuXMLCallback(&$node, $args)
{
$user = &JFactory::getUser();
$menu = &JSite::getMenu();
$active = $menu->getActive();
$path = isset($active) ? array_reverse($active->tree) : null; if (($args['end']) && ($node->attributes('level') >= $args['end']))
{
$children = $node->children();
foreach ($node->children() as $child)
{
if ($child->name() == 'ul') {
$node->removeChild($child);
}
}
}
if ($node->name() == 'ul') {
foreach ($node->children() as $child)
{
if ($child->attributes('access') > $user->get('aid', 0)) {
$node->removeChild($child);
}
}
}
if (($node->name() == 'li') && isset($node->ul)) {
$node->addAttribute('class', 'parent');
}
if (isset($path) && in_array($node->attributes('id'), $path))
{
if ($node->attributes('class')) {
$node->addAttribute('class', $node->attributes('class').' active');
} else {
$node->addAttribute('class', 'active');
}
}
else
{
if (isset($args['children']) && !$args['children'])
{
$children = $node->children();
foreach ($node->children() as $child)
{
if ($child->name() == 'ul') {
$node->removeChild($child);
}
}
}
}
if (($node->name() == 'li') && ($id = $node->attributes('id'))) {
if ($node->attributes('class')) {
$node->addAttribute('class', $node->attributes('class').' item'.$id);
} else {
$node->addAttribute('class', 'item'.$id);
}
}
if (isset($path) && $node->attributes('id') == $path[0]) {
$node->addAttribute('id', 'current');
} else {
$node->removeAttribute('id');
}
$node->removeAttribute('level');
$node->removeAttribute('access');
}
define('modMyMainMenuXMLCallbackDefined', true);
}
ob_start();//render the menu, and capture the output using output buffering
modMainMenuHelper::render($params, 'modMyMainMenuXMLCallback');
$menu_html = ob_get_contents();
ob_clean();
//You can use the "tag" parameter to apply this to only specific menus (not used in this example)
$tag = $params->get('moduleclass_sfx');
if(strtolower(trim($tag)) == "modal"){
echo roundedCornerPatch($menu_html,$params);
}else{
echo $menu_html;
}
ob_end_flush();
//output the menu!
?>
Now I have a menu where all items open in a modal dialog.
-Mike Fatica