routing and controllers |
[eluser]deineMudder[/eluser]
Hello, sadly i got another basic question i guess, where i lack understanding of CI. my actual controller folder looks like this Code: controllers im trying to create a small CMS for a site and thought that structure for the administration part could be handy. each controller (i.e. user.php) has the functions insert, edit, delete ... as soon as i try to access those controllers hes trying to load a function of admin controller (admin), function (user) instead of subfolder (admin), controller (user), function (index) anyone who could help a newbie to set it up correctly?
[eluser]marcoss[/eluser]
Hi there, I'm using the same approach, and is working fine, so probably routing is not working fine. How are you trying to access the controllers inside the directory?
[eluser]deineMudder[/eluser]
[quote author="marcoss" date="1182686701"]Hi there, I'm using the same approach, and is working fine, so probably routing is not working fine. How are you trying to access the controllers inside the directory?[/quote] as i said i just tried it with www.mydomain.com/admin/user to get to the user controller. i have no routing set up yet.
[eluser]marcoss[/eluser]
[quote author="deineMudder" date="1182687356"] as i said i just tried it with www.mydomain.com/admin/user to get to the user controller. i have no routing set up yet.[/quote] In that case, the user controller (inside admin dir) should have an index() function to handle the default requests. If you want to trigger an specific function by default, lets say manage users, you can do that this way. Code: class User extends Controller {
[eluser]deineMudder[/eluser]
[quote author="marcoss" date="1182687926"][quote author="deineMudder" date="1182687356"] as i said i just tried it with www.mydomain.com/admin/user to get to the user controller. i have no routing set up yet.[/quote] In that case, the user controller (inside admin dir) should have an index() function to handle the default requests. If you want to trigger an specific function by default, lets say manage users, you can do that this way. Quote:class User extends Controller {[/quote] /admin/user leads to a 404 instead to the proper controller in controllers/admin/user.php -> index()
[eluser]marcoss[/eluser]
mmm, is any of your controllers working? You said you have a homepage.php, is site.com/homepage working? If not, try using this structure, site.com/index.php/admin/user/index.
[eluser]deineMudder[/eluser]
yes my controllers are working found the problem i had a /controllers/admin.php from early testing. so CI identified admin/user as function of admin instead of seeing it as its own controller. ty anyway. the forum is a great help for starters like me.
[eluser]marcoss[/eluser]
That is the expected behaviour, I've just used the file tree you provided as a guide and didn't see the admin.php listed so i dismissed it as an option. Good to know that is solved now |
Welcome Guest, Not a member yet? Register Sign In |