Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't calling controller in codeigniter

I have two application in Codeigniter project. bellow is the structure:

/admin
    /index.php
/application
    /admin
        /controllers
           /Dashboard
           /Product
           /Post
    /public
        /controllers
           /Home
           /About
           /Contact
/system
/index.php

The public application can work normally. and I can call all of controllers with this setting:

/*----seting in /index.php---*/
$application_folder = 'application/public';

/*----seting in /application/public/config/config.php---*/
$config['base_url'] = 'http://localhost/myweb/';

/*----seting in /application/admin/config/routes.php---*/
$route['default_controller'] = 'Home';

but, The Admin application can't work normally. I only can be calling Dashboard controller which is the default controller that I was set. the setting look like this:

/*----setting in /admin/index.php---*/
$application_folder = '../application/admin';

/*----seting in /application/admin/config/config.php---*/
$config['base_url'] = 'http://localhost/myweb/admin/';

/*----seting in /application/admin/config/routes.php---*/
$route['default_controller'] = 'Dashboard';

so, when I visit:

http://localhost/myweb/                  //it will return home page
http://localhost/myweb/admin             //it will return dashboard page
http://localhost/myweb/admin/product     //it will return error

can anyone help me to fix this case?

like image 843
bagongpct Avatar asked Nov 07 '22 18:11

bagongpct


1 Answers

Why not seperate your admin area into a sub-directory, rather than having two application directories. That way your public controllers and admin controllers can share models, helpers, etc

So it would be:

/application
    /controllers
        /admin
            Index.php <-- admin controller inside 'admin' directory
        Index.php <-- public controller outside 'admin' directory
    /models
    /views
        /admin
        /public
like image 93
MrCarrot Avatar answered Nov 14 '22 23:11

MrCarrot