Check out my example from http://groups.google.com/group/cake-php/browse_thread/thread/cb8f54e19b46cc2e [messages 9 & 10]
I use it all the time for changing how URLs are generated on a site- wide basis - mainly for SEO, although it clearly has other uses. Basic summary: * Create app/app_helper.php to create AppHelper (extends Helper) * Override AppHelper::url() to first forward to Router::url() then transform the url All helpers (including HtmlHelper) will then inherit from your AppHelper and use its url() method. On Oct 3, 9:57 pm, rtconner <[EMAIL PROTECTED]> wrote: > Uhm, It's a bit of a hack, but when i needed to do something > similar... > I made a helper that extended HtmlHelper (called SHtmlHelper), and > then I overwrote the url method in that new helper. > Then at the top of my layout files I put > <? $html = $sHtml; ?> so now all instances of $html helper used my new > helper. > > I have no idea if this is best practice. Lets hope gwoo reads this > thread, and drops some advice down. > > On Oct 3, 12:31 pm, cyberhorst <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I need to transport some kind of ID (it could also be a Session-ID) > > through the URL. This could look like > > this:http://domain.com/ID1234/posts/edit > > orhttp://domain.com/ID7895/users/ > > This ID can easily be identified by a RegEx. > > The problem is how can cake pass this ID **automatically** to every > > other cake-generated URL on this page (like with html->link(), > > form->create() or redirect() - which all based on Router::url)? Do I have > > > to write my own link() and form() functions? > > > The easiest way would be to store this ID in a session, but I need to > > have different IDs in one browsersession and to access all pages > > directly, so I have to have the ID in the url. > > > I tried to set up a route: > > > Router::connect('/:MyID/:controller/:action/*',array(),array('MyID' => > > 'ID[0-9]{4}')); > > > but it did not work. Then I added something like this to core.php: > > > ereg("/(ID[0-9]{4})/",$_SERVER["REQUEST_URI"],$MyID); > > if ($MyID[1]) define ('BASE_URL', "/".$MyID[1]); > > > this worked reasonably but the value of $this->here is incorrect > > afterwards and it seemed to me that this is not a good way to do it. > > > Have you any ideas how to accomplish this? THANKS! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---
