Monday, March 9, 2015

Is it possible to use a record id in the front of the url

I need to set a record id in the url for all my pages. For example. If the user does not supply the id the site should always use 1000 as the default

eg. http:// www.demosite.com/1000.

If the user navigate to http:// www.demosite.com/1001. I set record 1001 details in a session and display it in an element. From here on forward I need all the urls to look like this.

http:// www.demosite.com/1001/about-us
http:// www.demosite.com/1001/wizard/step1
http:// www.demosite.com/1001/prices/view/1
http:// www.demosite.com/23001/products/view/1

I have tried the route below, witch works but I need to redirect and then I loose the 1001 record id in the url.

Router::connect('/:id', array('controller' => 'distributors', 'action' => 'session'), array('id' => '[0-9]+'));  Router::connect('/:id/**', array('controller' => 'distributors', 'action' => 'session'), array('id' => '[0-9]+'));


Can anyone help me with this please?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: