Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] URL dispatcher
#1

[eluser]sirtea[/eluser]
Let's supose we have subclassed model of objects

object_primary and object_secondary

i have a method index in controller objects that generates a menu-dispatcher to subclass options, and a sort of folders with their own controllers

Code:
/controllers
|-> objects.php
|-> objects
    |-> primary.php
    |-> secondary.php

I'm expecting a behaviour like
Code:
<url>/objects                    -> objects.php::index()
<url>/objects/primary/index      -> objects/primary.php::index()
<url>/objects/primary/add        -> objects/primary.php::add()
<url>/objects/primary/delete     -> objects/primary.php::delete()
<url>/objects/secondary/whatever -> objects/secondary.php::whatever()

It seems that codeignitere makes a mess with the repeated name of the folder and controller; if you rename one of them it works as expected, althous is kind of ugly.

¿Any suggestion?
#2

[eluser]WanWizard[/eluser]
The loader checks first if a controller exists, and if not, if it is a sub directory. And not the other way around.
So everything starting with /objects/ will load objects.php, and will ignore the folder.
#3

[eluser]sirtea[/eluser]
maybe i could use URI routing in config/routes.php to achieve what i want...
Perhaps if the controller has a different name...
if the route contains object/primary i could map to object2/primary.php...
I will investigate further.

thanks!




Theme © iAndrew 2016 - Forum software by © MyBB