Creating Custom URLs in Your Wheels App with Routes

December 18, 2008

Posted in Community

Posted By: Chris Peters

Today, I released a chapter in the <a href="http://www.cfwheels.com/docs">Documentation</a> called <a href="http://www.cfwheels.com/docs/chapter/using-routes">Using Routes</a>. Routes are a pretty cool feature of Wheels because they let you step outside of the <abbr title="Uniform Resource Locator">URL</abbr> convention that can sometimes feel like shackles. <!--more--> As I outline in the new chapter, you can create a <abbr title="Uniform Resource Locator">URL</abbr> like this: http://www.domain.com /user/johndoe With this line of code in your <kbd>config/routes.cfm</kbd> file: <div>&lt;cfset addRoute(name="userProfile", pattern="user/[username]", controller="user", action="profile")&gt;</div> <a href="http://www.cfwheels.com/docs/chapter/using-routes">Read on</a> to find out how it all works.
R
Raul Riera

Keep up the good work man hehe, if u need anything let us know. Btw is this blog running on wheels?

Oct 18, 2008

R
Raul Riera

Shouldn't this be http://www.domain.com/news/1/story/5 instead of http://www.domain.com/news/story/5 I think there should be an ID for the news right?

Oct 18, 2008

P
Chris Peters

@Raul: No, the format I have is correct. Match this... http://www.domain.com/news/story/5 To this... http://www.domain.com/controller/action/id And you get this... controller = news action = story id = 5 That is the default route for Wheels.

Oct 18, 2008

P
Chris Peters

Also, this blog is running on Ray Camden's BlogCFC. There was no need to re-invent the wheel on blogging platforms. We'll see if one gets implemented in Wheels in the future... :)

Oct 18, 2008

R
Raul Riera

Oh I see, I though it was a News tha hasMany Stories. I thought they were 2 models.

Oct 18, 2008

Latest Blog Posts