CodeIgniter Forums

Full Version: global controller functions / hierarchical controller configuration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]neph[/eluser]
i'm trying to set up some functions that extend the core controller class by using MY_controller.php in the libraries folder for pretty basic stuff like _admin_check(), _logged_in(), and a dynamic CRUD for related modules i've written. i was wondering if there was a better way to go about it that anybody could possibly share. Also i'm trying to figure out a clean way to set up a hierarchical controller configuration for an admin panel such as admin/users, admin/pages, admin/events...etc however creating the file structure of

controllers/admin.php
controllers/admin/users.php
controllers/admin/pages.php
controllers/admin/events.php


i cant seem to get working, with custom routes or stand-alone, and was wondering if anybody could shed some light onto an efficient solution.


any help is greatly appreciated.

El Forum

[eluser]TheFuzzy0ne[/eluser]
It's because of the admin.php file. Ideally, you should rename it to whatever the default controller is named, and put it inside your admin directory. Please note, however, that you'll only be able to access the index method of that controller. If you add another paramter, for example, yoursite.tld/admin/some_method it won't be called unless you add a route for each of those methods, or create a controller by that name in the admin directory instead.

Hope this makes sense.

El Forum

[eluser]neph[/eluser]
it does, and i had yet to update the forum but i figured that out. i have

controller/admin/admin.php with a route for $route['admin'] = 'admin/admin';
controller/admin/users.php
controller/admin/pages.php

thank you =)