Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 3 RC2 Admin developement guideline
#1

Hi there everyone.

I'm developing an html/css admin template with Codeigniter 3 RC2 to use as back-end of my sites. i want to develop it in way that i can use it with multiple sites. each of my site contains front-end and back-end. which share the same database and config file, everything else i keep separate.

i have a little issue, i need some expert advice on how to setup admin to work correctly.

all my links open at:

Code:
www.domain.com/manager/{page_name}

thats why i have one controller manager, but i want {page_name} (login, dashboard, orders) to be my controller, can is do this with codeigniter's MVC structure or do i need HMVC for that.

if HMVC is required where can i get one which will work with CI 3 RC2.

Thanks.
Reply
#2

You can add folders in the controllers folder.

In your case, create a folder called "manager" in the controllers folder. Then, in the manager folder you create a controller for each page you want. The path would now be www.domain.com/{folder}/{controller}/{function}, for example www.domain.com/manager/user/create

Hope that helps.
Reply
#3

(This post was last modified: 02-24-2015, 01:57 AM by summer.)

Hi Silentium!

Thanks for the reply, problem is almost solved.

how can i set routes for it so that next segment after "manager/" is a controller in manager(sub-directory in application/controllers).

it this right?

Code:
$route['manager/(:any)'] = 'manager/$1';
$route['manager'] = 'manager/manager';

how can i set the default controller for this sub-directory(manager)?

Thanks in advance.
Reply
#4

(This post was last modified: 02-24-2015, 05:05 AM by InsiteFX.)

/(:any) is a catch all route and needs to be the very last route in your routes file or none of the routes after it will work!

HMVC for CI 3.0
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

^Thanks for the routing tip, i have that HMVC but its not optimized for RC2, at least not yet. has some issues with autoloading session library.

another question:

I have some functions in each controller which are same for all. how can i make a common file for it and reuse in all admin controllers.

Thanks.
Reply
#6

Createe a MY_Controller and put all your common controller functions/methods in it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

^Thanks alot, i have already done that. will i be able to move to hmvc after using MY_Controller?
Reply
#8

(02-24-2015, 01:56 AM)summer Wrote: ...
how can i set routes for it so that next segment after "manager/" is a controller in manager(sub-directory in application/controllers).
...

There is no need to add anything to the routes config. CI supports sub folders in the controller directory by default.
Here is the documentation link http://www.codeigniter.com/userguide3/ge...irectories.

The only optional settings you might need is setting a default controller for the sub-directory. To do that, just add what you have on row 2 in the routes.php config.
Code:
$route['manager'] = 'manager/<default_controller>';

Regarding shared functions, I would go with a 'MY_Controller' as recommended by @InsiteFX
More info on how you do that can be found here http://www.codeigniter.com/userguide3/ge...asses.html
Reply
#9

^Thanks everyone for the help.
Reply
#10

(This post was last modified: 02-25-2015, 11:01 AM by InsiteFX.)

Yes, Your MY_Controller will extend the MX_Controller for HMVC.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB