Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated routing #18

Closed
xtrasmal opened this issue Oct 6, 2012 · 2 comments
Closed

Automated routing #18

xtrasmal opened this issue Oct 6, 2012 · 2 comments

Comments

@xtrasmal
Copy link

xtrasmal commented Oct 6, 2012

If I create a Post, which has a title and content, I would like to get a pretty link.
So instead of:

 /posts?id=2

I would like:

/posts/2012/10/06/My-cool-post

How would I proceed?

@jasonhinkle
Copy link
Owner

sure, you could do that with a route in the routemap (located in _app_config.php) like this:

'GET:posts/(:num)/(:num)/(:num)/(:any)' => array(
    'route' => 'Post.ShowPost', 
    'params' => array('year' => 1,'month' => 2,'day' => 3,'id' => 4)
),

Then in the controller (in this example PostController->ShowPost) you would get the value of "id" like this:

$this->GetRouter()->GetUrlParam('id');

@jasonhinkle
Copy link
Owner

I think this is resolved, if not feel free to re-open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants