Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Automatically passing url-segments as variables to methods
#1

[eluser]trice22[/eluser]
Hello,

I'm afraid, that I've just missed something, but is it somehow possible to receive the url-segments 3,4,… automatically as variables in the method (segement 2)?
I thought I'd have seen that in Kohana and was wondering, if there's something like this for CI as well existing?

Example:
Code:
/*

Example URL:

http://www.mydomain.com/user/edit/2/something

*/

class User extends Controller {

    function edit($id, $variable)
    {
        // Here I'm editing the user with ID 2, using $variable = something
        // Usually:
        // $id = $product_id = $this->uri->segment(3);
        // $variable = $product_id = $this->uri->segment(4);
    }
}

Thanks,
—trice
#2

[eluser]Ainab[/eluser]
I think CI does not support that and that might defeat the purpose of having segment function.
#3

[eluser]christian.schorn[/eluser]
CI does support this, see Passing URI Segments in the user guide.
#4

[eluser]trice22[/eluser]
Damn'—I knew the risk to make a fool out of myself was high Big Grin
Thanks a bunch, Christian.

—trice




Theme © iAndrew 2016 - Forum software by © MyBB