Subhash Shipu
Subhash Shipu

Reputation: 341

How to add a folder in HMVC structure CodeIgniter?

I have file structure in CodeIgniter for HMVC everything is working fine

But I want file structure like

modules
    admin
        user
            controller
            view
            model
        profile
            controller
            view
            model
    frontend
        login
,           controller
            view
            model

Currently it's working fine with this file structure

modules
    user
        controller
        view
        model
    profile
        controller
        view
        model

So how can use as i mentioed above i just to add a folder before.

I want the URL like example.com/admin/user

Currently working example.com/user

Upvotes: 0

Views: 214

Answers (1)

Taufik Arief Widodo
Taufik Arief Widodo

Reputation: 58

You can set your route like this

$route['admin/([a-zA-Z_-]+)/(:any)/(:any)'] = '$1/$1_admin/$2/$3';
$route['admin/([a-zA-Z_-]+)/(:any)'] = '$1/$1_admin/$2';
$route['admin/([a-zA-Z_-]+)'] = '$1/$1_admin/index';

And change your class name controller Like this

class User_admin extends CI_Controller
{
 ...
}

You can see my code on github github.com/caktopik/haci

Or if you want to create admin panel please read this https://philsturgeon.uk/codeigniter/2009/07/08/Create-an-Admin-panel-with-CodeIgniter/

Upvotes: 1

Related Questions