Yii渲染部分菜单标题 - 不同模块的不同菜单内容

时间:2018-04-24 06:21:28

标签: php yii

我想将标题代码分隔到/layouts/_header.php和页脚到/layouts/_footer.php并在我的模块中呈现它们:

<?php echo $this->renderPartial('//layouts/_header'); ?>

我遇到了问题,因为我的通用标头有一个副标题,而且有些模块有不同的副标题内容。

_header.php

<style type="text/css">

    .header__fnav .navbar-brand{
    background:#fff;
    }

    .header__fnav .navbar-brand .st0{
        fill:#00AAC6;
    }
    .header__fnav .navbar-brand .st1{
        fill:#CE3640;
    }
    .header__fnav .navbar-brand .st2{
        fill:#F3A629;
    }
    .header__fnav .navbar-brand .st3{
        fill:#6EA945;
    }
    .header__fnav .navbar-brand .st4{
        fill:#E75C2D;
    }
    @media (min-width: 1200px)
    {
        .uni-header .header__fnav .navbar-brand {
            height: 40px;
            margin-left: 0;
            margin-right: 20px;
            height: 40px;
            line-height: 35px;
            padding: 12px 0;
            width: 42px;
            margin-left: 0!important;
        }
    }
    .header__fnav .navbar-brand svg {
        height: 15px !important;
        width: 18px !important;

    }
</style>


<header class="header">
    <div class="uni-header">
        <nav class="navbar header__fnav" data-spy="affix" data-offset-top="1">
            <div class="container container_dark">
            </div>
            <div class="container">
                <div class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-right">
                    <button type="button" class="toggle-menu menu-right navbar-toggle">
                    <span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </span>
                    </button>
                    <a class="logo_main hidden-xs hidden-sm" href="https://mymagic.my/">
                        <img width="119" height="20" src="https://mymagic.my/wp-content/themes/magic2017/assets/art/logo.svg" alt="MaGIC">
                        <span class="header__tagline hidden-xs hidden-sm">Malaysian Global Innovation &amp; Creativity Centre</span>
                    </a>
                    <?php $this->renderBreadcrumb(true) ?>
                    <div class="box_white">
                        <form class="search_block" action="https://mymagic.my/">
                            <div class="dropdown">
                                <a class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" href="#">
                                    <i class="icon-search"></i>
                                </a>
                                <div class="dropdown-menu">
                                    <fieldset>
                                        <input type="search" class="form-control" placeholder="Search" value="" name="s">
                                        <button type="button" class="close" data-dismiss="dropdown-menu" aria-label="Close"><i class="icon-close"></i></button>
                                        <button type="submit"><i class="icon-search"></i></button>
                                    </fieldset>
                                </div>
                            </div>
                        </form>
                        <ul class="nav_pillars">

                            //This is the subheader part 


                        </ul>
                    </div>
                    <ul class="nav_main hidden-md hidden-lg">
                        <li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="https://mymagic.my/about/" class="menu-link main-menu-link">About</a></li>
                        <li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="https://mymagic.my/programs/" class="menu-link main-menu-link">Programs</a></li>
                        <li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="https://mymagic.my/events/" class="menu-link main-menu-link">Events</a></li>
                        <li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="https://mymagic.my/facilities/" class="menu-link main-menu-link">Co-Working</a></li>
                        <li class="menu-item menu-item-type-custom menu-item-object-custom"><a target="_blank" href="http://resource.mymagic.my/#sthash.ETSyAo9e.dpbs" class="menu-link main-menu-link">Resources</a></li>
                        <li class="menu-item menu-item-type-custom menu-item-object-custom"><a href="https://mymagic.my/ace/" class="menu-link main-menu-link">ACE</a></li>
                        <li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="https://mymagic.my/news/" class="menu-link main-menu-link">News</a></li>
                        <li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="https://mymagic.my/publications/" class="menu-link main-menu-link">Publications</a></li>
                    </ul>
                    <ul class="nav_secondary hidden-md hidden-lg">
                        <li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="https://mymagic.my/jobs/" class="menu-link main-menu-link">Jobs</a></li>
                        <li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="https://mymagic.my/contact/" class="menu-link main-menu-link">Contact Us</a></li> 
                    </ul>
                    <ul class="nav_main nav_myacc hidden-md hidden-lg">
                        <li><a href="http://connect.mymagic.my/"><i class="icon-key"></i> My Account</a></li>
                    </ul>
                </div>
            </div>
        </nav>
    </div>
</header>

如何在我的模块中渲染它并填写每个模块的子标题部分?

所以说我的x模块 - 我有这些子标题选项 - 我不知道如何渲染部分标题并在其中包含这些子标题菜单。

        <ul class="nav_pillars">

            <li role="presentation" class="<?php if($this->activeMenuMain=="start"): ?>active<?php endif; ?>"><a href="<?php echo $this->createUrl('//idea/frontend/index') ?>">Get Started</a></li>
            <li role="presentation" class="<?php if($this->activeMenuMain=="explore"): ?>active<?php endif; ?>"><a href="<?php echo $this->createUrl('//idea/frontend/explore') ?>">Explore</a></li>
            <li role="presentation" class="<?php if($this->activeMenuMain=="about"): ?>active<?php endif; ?>"><a href="<?php echo $this->createUrl('//idea/frontend/about') ?>">About</a></li>
            <?php if(!Yii::app()->user->isGuest): ?>
            <li role="presentation" class="<?php if($this->activeMenuMain=="manage"): ?>active<?php endif; ?>"><a href="<?php echo $this->createUrl('//idea/frontend/manageOrganizations') ?>">Manage</a></li>
            <li role="presentation" class="dropdown hidden <?php if($this->activeMenuMain=="manage"): ?>active<?php endif; ?>">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Manage <i class="icon-down-open-big"></i>
                </a>
                <ul class="dropdown-menu">
                    <li class="<?php if($this->activeMenuSub=="manageOrganizations"): ?>active<?php endif; ?>"><a href="<?php echo $this->createUrl('//idea/frontend/manageOrganizations') ?>">Organisations</a>
                    <li class="<?php if($this->activeMenuSub=="managePartners"): ?>active<?php endif; ?>"><a href="<?php echo $this->createUrl('//idea/frontend/managePartners') ?>">Partners (deprecated)</a></li>
                    <li class="<?php if($this->activeMenuSub=="manageEnterprises"): ?>active<?php endif; ?>"><a href="<?php echo $this->createUrl('//idea/frontend/manageEnterprises') ?>">Enterprises (deprecated)</a></li>
                    <li class=""><a href="<?php echo $this->createUrl('//cpanel') ?>"><?php echo Yii::app()->name ?></a></li>                           
                </ul>
            </li>
            <li role="presentation" class="<?php if($this->activeMenuMain=="logout"): ?>active<?php endif; ?>"><a href="<?php echo $this->createUrl('//site/logout', array('returnUrl'=>$this->createAbsoluteUrl('/idea'))) ?>" title="<?php echo $this->user->username ?>" data-toggle="tooltip" data-placement="bottom">
                <img src="<?php echo ImageHelper::thumb(100, 100, $this->user->profile->image_avatar) ?>" class="img-circle" style="width:24px; height:24px" /> Logout
            </a></li>
            <?php else: ?>
            <li role="presentation" class="<?php if($this->activeMenuMain=="login"): ?>active<?php endif; ?>"><a href="<?php echo $this->createUrl('//site/login', array('returnUrl'=>$this->createAbsoluteUrl('/idea'))) ?>">Login</a></li>
            <?php endif; ?>
        </ul>

0 个答案:

没有答案