[CakePHP] alias in the url

The task was to have “aliases” for url. For example let’s think about a ProjectsController; each project is characterized by a unique id, a unique name and some other attributes. With the cake way you can refer to the projects with /projects/add, /projects/edit/$id, /projects/delete/$id and /projects/view/$id.

I would like to have an alias for the view: call each project even with a url like /projects/$name (friendlier url).

I achieved the task extending the ErrorHandler::missingAction(). Here is the code I used (pdf).

I don’t know if this is the proper way to do this but it’s working.

2 Comments »

  1. [CakePHP] Alias in the url. Take 2 « /home/edivad said,

    May 6, 2008 @ 11:17 am

    [...] web ·Tagged alias, cakephp, php, programming, url, web Some days ago, I posted about having dynamic URL aliases with cake-php 1.1.18. In that post I used the AppError object trapping the missingAction [...]

  2. Wharfage said,

    June 19, 2008 @ 9:34 am

    Somehow i missed the point. Probably lost in translation :) Anyway … nice blog to visit.

    cheers, Wharfage.

RSS feed for comments on this post · TrackBack URI

Leave a Comment