简体   繁体   English

为每个joomla菜单级别定义自定义布局和类

[英]Define custom layout & class to each joomla menu levels

I want to add custom layout and class to joomla menu levels. 我想向joomla菜单级别添加自定义布局和类。

This is the default.php codes of my menu 这是我菜单的default.php代码

<nav class="uk-navbar <?php echo $class_sfx; ?>" id="ad-menubar">
<ul class="uk-navbar-nav">
<?php foreach ($list as $i => &$item){
    $class = 'ad-menu-item item-' . $item->id;
    $attribute = '';

    if ($item->id == $default_id)
    {
        $class .= ' default';
    }


    if (($item->id == $active_id) || ($item->type == 'alias' && $item->params->get('aliasoptions') == $active_id))
    {
        $class .= ' current';
    }

    if (in_array($item->id, $path))
    {
        $class .= ' uk-active';
    }
    elseif ($item->type == 'alias')
    {
        $aliasToId = $item->params->get('aliasoptions');

        if (count($path) > 0 && $aliasToId == $path[count($path) - 1])
        {
            $class .= ' active';
        }
        elseif (in_array($aliasToId, $path))
        {
            $class .= ' alias-parent-active';
        }
    }

    if ($item->type == 'separator')
    {
        $class .= ' divider';
    }

    if ($item->deeper)
    {
        $class .= ' deeper';
    }

    if ($item->parent)
    {
        $class .= ' uk-parent';
        $attribute = "data-uk-dropdown=\"{justify:'#ad-menubar', mode:'click'}\"";
    }

    echo '<li class="' . $class . '" '. $attribute .'>';

    switch ($item->type) :
        case 'separator':
        case 'component':
        case 'heading':
        case 'url':
            require JModuleHelper::getLayoutPath('mod_menu', 'default_' . $item->type);
            break;

        default:
            require JModuleHelper::getLayoutPath('mod_menu', 'default_url');
            break;
    endswitch;

    // The next item is deeper.
    if ($item->deeper)
    {
        echo '<div class="uk-dropdown uk-dropdown-navbar"><ul class="uk-nav uk-nav-navbar">';
    }
    // The next item is shallower.
    elseif ($item->shallower)
    {
        echo '</li>';
        echo str_repeat('</ul></div></li>', $item->level_diff);
    }
    // The next item is on the same level.
    else
    {
        echo '</li>';
    }
}
?>
</ul>
</nav>

its deeper levels generated with this code 此代码生成的更深层次

if ($item->deeper)
    {
        echo '<div class="uk-dropdown uk-dropdown-navbar"><ul class="uk-nav uk-nav-navbar">';
    }
    // The next item is shallower.
    elseif ($item->shallower)
    {
        echo '</li>';
        echo str_repeat('</ul></div></li>', $item->level_diff);
    }
    // The next item is on the same level.
    else
    {
        echo '</li>';
    }

I want to add custom divs and classes to each levels of dropdown for example I want to make third level menu multi column how could I define each level divs please help me I need it now its very important ... 我想将自定义div和类添加到下拉菜单的每个级别,例如,我想使第三级菜单多列,如何定义每个级别的div,请帮助我,我现在需要它非常重要...

Edit each menu item in Menu Manager and enter a Page Class under the Page Display Tab. 在菜单管理器中编辑每个菜单项,然后在页面显示选项卡下输入页面类。

You will then have unique selector classes in CSS to apply whatever styling you wish. 然后,您将在CSS中拥有唯一的选择器类,以应用所需的任何样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM