Welcome Guest, Not a member yet? Register   Sign In
Not compatible ? : "_remap" function and "Passing URI Segments to your Functions"
#4

[eluser]sophistry[/eluser]
hi solito,

thank you for the spirited and learned discussion!

[quote author="Solito" date="1253127522"]- In my first example, we don't have to use *explicitly* the URI object to access segments 2 and 3 : it works without using $this->uri->segment, okay ?[/quote]
yes, that is true. But that is because the CI core is passing the parameters to the controller function. i'm not saying "that's the way it should be" just "that's the way it is". :-)
[quote author="Solito" date="1253127522"]
- So tell me how could we guess that this *silent* use of URI object is no longer possible when using remap ?
[/quote]
as i said in my first reply, the reason the parameters are not passed to the test() method (in your example) is because the code you wrote is not passing them from within _remap() when it calls
Code:
$this->$methode;
[quote author="Solito" date="1253127522"]
What's more, Remap accepts one parameter only. It means that I would have to pass the rest of the segment as an array to the remaped function. There isn't another way ?[/quote]

yes, that is true. i suggest rewriting the test() method so that it uses the native URI object. that way, you can be sure that the controller function will work whether it is called by the CI core or by your _remap() function.

alternatively, you could look at re-writing _remap() and figure out how to pass parameters automatically like the CI routing class does.

of those two ideas, i would choose the easier one. but, that's just me.

cheers.

EDIT: by the way, please look at how I use _remap() in the site_migrate wiki page linked in my signature below each post. i faced the same issue and after writing some code that would pass the ruri string out of the _remap() method, i decided to just use the URI object in the receiving controller methods.

i don't recommend this, but you might like it:
Code:
$this->$methode($this->uri->ruri_string());


Messages In This Thread
Not compatible ? : "_remap" function and "Passing URI Segments to your Functions" - by El Forum - 09-16-2009, 08:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB