• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split controller


I start working with codeigniter.
I have one Controller (called Pages default one) that contains all my functions.
I would like to split the file in several Controller to group by application section (House, Resident, Rentals, Utilities)
How can I achieve that?
I created server files at the same level that the main controller

It think that my main issue is about the url invoked by the views...
i.e. my navigation (views/templates/navigation.php) use the function name (logical) as href (<a href="rentals">...)
rentals being a function within Pages.php; if I move the rentals function within Rentals.php; I have of course a 404.

For information, my Routes.php contains the following
$route['default_controller'] = 'pages/index';
$route['(:any)'] = 'pages/$1';

I hope I am clear Smile

I found a solution: custom libraries...
In my Page.php controller I have now:
public function houses() {
And I have a library file HouseLib.php with this:
class HousesLib {
public function index() {
$CI = & get_instance();
if ($CI->session->userdata('is_logged_in')) {

PHP Code:
$route['(:any)'] = 'pages/$1'

This is basically sending everything to your pages controller, so you can't really use any other controllers without setting up routes for them above this one.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.