RBAM menus urls

I have a bit of confusion regarding the RBAM menu, which I render as part of a larger "admin" menu within an ap.

The following entry is in the main view layout:

array('label'=>'Admin', 'items'=>array(


    array('label'=>'Roles and Authorizations', 'url'=>array('/rbam/rbam/index'), 'items'=>Yii::app()->findModule('rbam')->getMenuItems()),

Config contains:

'rbam'=>array(


'initialise'=>'/protected/data/auth.php',


'development'=>true,


'applicationLayout'=>'application.views.layouts.test',


),

The problem I’m seeing is that while the url for the top-level is correct (rbam/rbam/index), the urls for all sub-menu items are all missing the top-level “rbam” module context. So, for instance, the authItems page shows authItems/index, not rbam/authItems/index. If I visit the top-level page, then look at the menu items in question, they are correct.

I tried using the baseUrl config param, thinking that that could be used to force the rbam module context (since I suspect this is happening because the module context for the other pages is null), but I may not be specifying it correctly.

So, is there something I should be doing that I’m not? Can someone indicate a proper config setting to use in this case, to force the module of those menu entries?

Any info appreciated.

Some clarification.

Within CWidget.php:

    /**


     * Returns the controller that this widget belongs to.


     * @return CController the controller that this widget belongs to.


     */


    public function getController()


    {


            if($this->_owner instanceof CController)


                    return $this->_owner;


            else


                    return Yii::app()->getController();


    }

Within CMenu.php:

/**


 * Initializes the menu widget.


 * This method mainly normalizes the {@link items} property.


 * If this method is overridden, make sure the parent implementation is invoked.


 */


public function init()


{


	$this->htmlOptions['id']=$this->getId();


	$route=$this->getController()->getRoute();


	$this->items=$this->normalizeItems($this->items,$route,$hasActiveChild);


}

Within view layout rendering the menu:

    $this->widget('application.extensions.mbmenu.KsMenu',array(


        'items'=>array(


            array('label'=>'Something', 'url'=>array('/something/index'), 'items'=>array(...)),


            array('label'=>'Admin', 'url'=>array('/manage/index'), 'items'=>array(


                array('label'=>'Roles and Authorizations', 'url'=>array('/rbam/rbam/index'), 'items'=>Yii::app()->findModule('rbam')->getMenuItems()),

Question:

When rendering the menu, the owner context is set properly if I’m on an RBAM page already

but otherwise it’s not. So, for instance, I see authAssignments/index instead of

rbam/authAssignments/index. Thought findModule() would force good owner setting; should

I be doing something else there?

Thanks.

Use Yii::app()->getModule(‘rbam’)->getMenuItem() (not getMenuItems()) when using in this way.

getMenuItems() is for use when adding a standalone menu on a page, getMenuItem() for adding RBAM under a menu item.

Hope this helps.

Thanks for the response Yeti. However, I’m still a bit confused; I make the following call, as you indicate:

$rbamMenu = Yii::app()->getModule(‘rbam’)->getMenuItem();

Yii::trace('From rbam getMenuItem: '.print_r($rbamMenu, true), “info”);

and I see the following snippet:

2011/12/28 20:22:22 [trace] [info] From rbam getMenuItem: Array

(

[label] => RBAM


[url] => Array


    (


        [0] => rbam/rbam/rbam


    )





[linkOptions] => Array


    (


        [title] => Manage Roles & Assignments


    )





[items] => Array


    (


        [0] => Array


            (


                [label] => Auth Assignments


                [url] => Array


                    (


                        [0] => authAssignments/index


                    )





                [active] => 


                [visible] => 1


            )

But I’m looking to see the Auth Assignments entry (and others) having the module prefix, like:

                [label] => Auth Assignments


                [url] => Array


                    (


                        [0] => rbam/authAssignments/index


                    )





                [active] => 


                [visible] => 1

I can run through the entries and prepend the “rbam/”, but have a feeling I’m missing something…

Thanks again for the help.