Welcome Guest, Not a member yet? Register   Sign In
Routing: Passing entire expression as unique argument
#2

[eluser]Tim Brownlaw[/eluser]
Hi,

You need to use the URI Class to obtain the info from the segments in the URL. Check out the userguide on that.

In your case you are not altering the URL at all so you do not need to use routing.

Even if you are using routing you still need to use the URI Class.

When you would use routing

Routing is used if you want to have your URL like..
/articles/2010/June/24

Which would need to be routed to /articles/display/2010/June/24
controller = articles and the method = display with the rest of the information tacked on.

In routes.php
$route['articles/:any'] = "articles/display/$1"; creating the link above...

SO you are translating your url of
/articles/2010/June/24 to /articles/display/2010/June/24 and you then need to read in the segments with the information you are after, that being 2010/June/24.

In your Articles Controller, in the display method you would have this snippet.

Code:
$year = $this->uri->segment(3);
$month = $this->uri->segment(4);
$day = $this->uri->segment(5);

(I might have the indexes wrong )

And then do what you need to from there.

Hope that helps.

Cheers
Tim


Messages In This Thread
Routing: Passing entire expression as unique argument - by El Forum - 04-06-2010, 05:02 AM
Routing: Passing entire expression as unique argument - by El Forum - 04-06-2010, 05:31 PM
Routing: Passing entire expression as unique argument - by El Forum - 04-07-2010, 03:20 AM
Routing: Passing entire expression as unique argument - by El Forum - 04-07-2010, 03:54 AM
Routing: Passing entire expression as unique argument - by El Forum - 04-07-2010, 04:02 AM
Routing: Passing entire expression as unique argument - by El Forum - 04-07-2010, 09:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB