The url is what tells cake what to do. If you "hide" the id you remove the id and Cake will have not idea what id you want. The url must contain some kind of unique identifier...but not specifically the numeric id from the database.
You need to alter your action so it can use the make and model names to locate the car you want. Look at the footer of your post. The nabble url does not contain a numeric id but rather a readable name for the post. This is usually called a slug. Do a search on that word and you will find a lot of nice stuff like a behaviour to help you out and Cake classes helping you out with generating unique "names" for items in your database. You can either make a full slug for each car or one set of slugs for makes and one for models... hoping that noone makes two cars of the same name. /Martin On Sep 3, 12:15 pm, hahmadi82 <[email protected]> wrote: > I have a hyperlink defined as: > > echo $html->link(__('Discuss', true), array('controller' => 'cars', > 'action'=>'view', $car['Car']['id'], $car['Car']['make'], > $car['Car']['model'])); > > How can I define a route that changes the url from > '/cars/view/14/nissan/maxima' to '/cars/nissan/maxima'?? > > I did Router::connect('/cars/*', array('controller'=>'cars', 'action' => > 'view')) which got rid of the 'view' but not then I'm stuck with the 'id' > > I tried something like: > Router::connect('/car/:make/:model', array('controller'=>'cars', 'action' => > 'view'), array('pass' => array('id', 'make', 'model'))); > > but that didn't seem to hide the id. Any help would be much appreciated, > thanks! > -- > View this message in > context:http://www.nabble.com/How-to-hide-id-with-router%3A%3Aconnect-tp25273... > Sent from the CakePHP mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
