Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create submodules in yii2

I am using yii2 framework. I have two pages business and contact. I have used CRUD to generate the pages. Now I have to get one sub module to access contact when I use business page. I have to get access from business page to contact using URL. Once I click contact from business page it should redirect me to the contact page. What should I do? I have tried to create modules in gii. But I am not getting class IndexAction as well.

<?php
namespace app\modules\help\controllers;

use yii\base\Action;

class IndexAction extends Action
{

    public function run()
    {
        $this->controller->render('index');
    }

}
like image 980
user4809486 Avatar asked Apr 30 '15 11:04

user4809486


1 Answers

Yii2 supports nested modules. It's covered in documentation here.

Here is basic example:

namespace app\modules\forum;

class Module extends \yii\base\Module
{
    public function init()
    {
        parent::init();

        $this->modules = [
            'admin' => [
                // you should consider using a shorter namespace here!
                'class' => 'app\modules\forum\modules\admin\Module',
            ],
        ];
    }
}
like image 178
arogachev Avatar answered Oct 02 '22 02:10

arogachev