We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to i replicate header(with some dropdowns) in elements.php in INVO phalcon

Below is my code.....

                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Settings <span class="caret"></span></a>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="/wallet/subscribe>Subscribe</a></li>
                            <li><a href="/wallet/view"> Employee</a></li>                                
                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Manage Expenses <span class="caret"></span></a>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="/wallet/create">Create</a></li>
                            <li><a href="/wallet/report">Report</a></li>                
                            <li><a href="/wallet/tag">Tag</a></li>
                            <li><a href="/wallet/approval">Approve</a></li>
                        </ul>
                    </li>

Now i want to replicate the above code in INVO header format....

private $_headerMenu = array( 'navbar-left' => array( 'index' => array( 'caption' => 'Home', 'action' => 'index' ), 'invoices' => array( 'caption' => 'Wallets', 'action' => 'index' ), 'about' => array( 'caption' => 'About', 'action' => 'index' ), 'contact' => array( 'caption' => 'Contact', 'action' => 'index' ), ), 'navbar-right' => array( 'session' => array( 'caption' => 'Log In/Sign Up', 'action' => 'index' ), ) );

Or simply i want to get a dropdown in header menu. How to it? Please help!!!



43.9k
edited Oct '16

Hi,

You will have to code it in https://github.com/phalcon/invo/blob/master/app/library/Elements.php#L13: and add your menu items and tell that if you've got a submenu or not


    private $_headerMenu = array(
        'navbar-left' => array(
            'index' => array(
                'caption' => 'Home',
                'action' => 'index',
                'sub' => FALSE
            ),
            'invoices' => array(
                'caption' => 'Invoices',
                'action' => 'index'',
                'sub' => FALSE
            ),
            'about' => array(
                'caption' => 'About',
                'action' => 'index'',
                'sub' => FALSE
            ),
            'contact' => array(
                'caption' => 'Contact',
                'action' => 'index'',
                'sub' => FALSE
            ),
            'wallet' => array(
                'caption' => 'wallets',
                'action' => 'index',
                'sub' => array(
                    'create' => 'Create',
                    'report' => 'Report'
                )
        ),
        'navbar-right' => array(
            'session' => array(
                'caption' => 'Log In/Sign Up',
                'action' => 'index'',
                'sub' => FALSE
            ),
        )
    );

then in https://github.com/phalcon/invo/blob/master/app/library/Elements.php#L86 customize the code to render your submenu with an if else statement for checking if there is a submenu or not