Friday, May 15, 2015

How to access any behavior function in humhub (Developed in Yii Framework) ?

Access behavior function in humhub:

For access any behavior function we have to create a behavior function on our file in which we direct set its class.

By adding the SpaceControllerBehavior you are able to access current space in your controllers.
Make sure you always pass the current space guid (sguid) in your urls.

When using the method createContainerUrl (provided by SpaceControllerBehavior or UserControllerBehavior) the
current space or user guid is automatically added to urls.

    public function behaviors()
    {
        return array(
            'SpaceControllerBehavior' => array(
                'class' => 'application.modules_core.space.behaviors.SpaceControllerBehavior',
            ),
        );
    }

    public function actionTest() {
        $currentSpace = $this->getSpace();
       
        $this->redirect($this->createContainerUrl('test2'));
       
    }

    public function actionTest2() {
        $currentSpace = $this->getSpace();
    }


Thanks

No comments:

Post a Comment