Welcome Guest, Not a member yet? Register   Sign In
default controller in sub folder
#1

In Tutorial/Create news items/Routing section I see $route['default_controller'] = 'pages/view' line. This means we can assign controller in a subfolder as default controller. But I get 404 Page Not Found error when I assign 'website/home' (Home.php controller file in website directory) as default controller. Any idea?
Reply
#2

No, it means you can also include the method in there as well. Syntax is 'controller/method'.
Reply
#3

This what i do

$route['setting'] = "m_admin/setting/sidebar";

m_admin is folder name, Settings is controller name and sidebar is function name
Reply
#4

@Narf 1- It is working in CI 2.2 (folder/controller).
2- In CI 3.0 ChangeLog Core/Routing section it says - Added support for per-directory default_controller and 404_override classes.
3- In Bug Fixes section - Fixed a bug - :doc:`Routing Library <general/routing>` didn't properly handle default_controller in a subdirectory when a method is also specified.

I think here is a bug or backward incompatibility.
Reply
#5

(11-06-2014, 06:58 PM)bobykurniawan Wrote: This what i do

$route['setting'] = "m_admin/setting/sidebar";

m_admin is folder name, Settings is controller name and sidebar is function name

That is what you've done in CI2, you are in the "CodeIgniter 3.x" forum.

(11-06-2014, 08:38 PM)obozdag Wrote: @Narf 1- It is working in CI 2.2 (folder/controller).
2- In CI 3.0 ChangeLog Core/Routing section it says - Added support for per-directory default_controller and 404_override classes.
3- In Bug Fixes section - Fixed a bug - :doc:`Routing Library <general/routing>` didn't properly handle default_controller in a subdirectory when a method is also specified.

I think here is a bug or backward incompatibility.

1. Yes, I know it's "working" in CI 2.2.
2. Yes, and it works in a completely different way.
3. Yes, this bug is what has allowed you to say 1. It was a bug that you were able to do that. Smile
Reply
#6

2- That means
I can assign default controllers for http://website.com/admin (admin is a subfolder in controllers folder) or http://website.com/public (public is a subfolder in controllers folder) but I can't assign default controller for http://website.com. It is possible to have default controllers for subfolders but impossible for root. It seems unreasonable.
Reply
#7

(This post was last modified: 11-07-2014, 02:25 AM by ciadmin.)

Funny - I was asked this question privately a few hours ago Undecided

This is what I determined...

With CI3, if you have defined your default controller to be "whatever", then the router will look for that controller inside any URI which is in fact a sub-sub-sub...directory inside application/controllers.

/my/wonderful/web/stuff would be resolved by application/controllers/my/wonderful/web/stuff/Whatever->index() using the above.

It could also be resolved by application/controllers/my/wonderful/Web->stuff().

Or it could be resolved by application/controllers/my/Wonderful->web('stuff')

Or by application/controllers/My->wonderful('web','stuff')

Oh my! Can this be right? AM I stuck in a loop? Dig into the code and check it out!

ps A matching custom route, in config/routes.php, would override the above.
Reply
#8

(11-07-2014, 12:54 AM)obozdag Wrote: 2- That means
I can assign default controllers for http://website.com/admin (admin is a subfolder in controllers folder) or http://website.com/public (public is a subfolder in controllers folder) but I can't assign default controller for http://website.com. It is possible to have default controllers for subfolders but impossible for root. It seems unreasonable.

No, it doesn't mean that. As I said - it works in a completely different way.

https://github.com/bcit-ci/CodeIgniter/issues/2849
Reply




Theme © iAndrew 2016 - Forum software by © MyBB