Add A New Menu Item

Now we will discuss about How to manupulate menu in SE.

Actually SE does not provide any Iterface for Menu in admin section. We have to edit Database for creating a new menu

Module Menu

INSERT IGNORE INTO `engine4_core_menuitems` (`name`, `module`, `label`, `plugin`, `params`, `menu`, `submenu`, `order`) VALUES
('core_admin_main_plugins_[modulename]', '[modulename]', '[Module Level]', '', '{"route":"admin_default","module":"[modulename]","controller":"[controllername]","action":"[actionname]"}', 'core_admin_main_plugins', '', [order]);

Here
core_admin_main_plugins = Plugins Manin Menu[if we use it then our module will display under Plugin Menu]
core_admin_main = Main Menu [if we use it, it will show in main nave bar]

ex.

('core_admin_main_plugins_sport', 'sport', 'Sport', '', '{"route":"admin_default","module":"sport","controller":"manage","action":"browse"}', 'core_admin_main_plugins', '', 999);

Sub menu Under it.

('[modulename]_admin_main_[uniquename]', '[modulename]', '[Menu Level]', '', '{"route":"admin_default","module":"[modulename]","controller":"[controllername]","action":"[actionname]"}', '[modulename]_admin_main', '', [order]);

ex.

('sport_admin_main_manage', 'sport', 'Manage Sports', '', '{"route":"admin_default","module":"sport","controller":"manage","action":"browse"}', 'sport_admin_main', '', 1),

Calling

In Controller

$this->view->VariableThatUseInView = Engine_Api::_()->getApi('menus', 'core')
                ->getNavigation('[main_menu_name]', array(), '[active_sub_menu]');

ex.
Here
VariableThatUseInView = navigation
main_menu_name = sport_admin_main
active_sub_menu = sport_admin_main_manage

$this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')
                ->getNavigation('sport_admin_main', array(), 'sport_admin_main_manage');

In View

<?php if (count($this->navigation)): ?>
    <div class='tabs'>
        <?php
        echo $this->navigation()->menu()->setContainer($this->navigation)->render()
        ?>
    </div>
<?php endif; ?>
Advertisements

Tagged: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: