I don't seem to recall that working either. The only time it did work was when visiting the URL directly.
On May 8, 12:46 pm, majna <majna...@gmail.com> wrote: > what about pagination URL's with prefix routing? > > On May 8, 12:38 pm, geoff <garbet...@gmail.com> wrote: > > > It's not useless -- it does still work. It just doesn't work in the > > reverse direction. If I visit /wap/users/login, I'm routed correctly > > to UsersController::wap_login. However, it's when I try to create the > > URL in the page it self, so essentially saying "these are the params > > that I want you to map to a route with a custom prefix" that doesn't > > seem to provide the correct URL. > > > In my experience, it's halfway there at least ;) > > > On May 8, 12:32 pm, majna <majna...@gmail.com> wrote: > > > > I have same issue. > > > Prefix routing is useless. (reverese routing, pagination...) > > > "Routing.admin" accepts only one prefix. > > > > I would like to see prefix routing fixed ASAP in cake :) > > > > On May 8, 11:45 am, geoff <garbet...@gmail.com> wrote: > > > > > Hey all. This is pretty much a copy-paste of what I've just posted on > > > > my blog, but it's still related to the current topic... > > > > > After having worked on a particularly annoying problem involving the > > > > CakePHP custom prefix routing, I feel like I might have found a slight > > > > bug in the reverse routing (specifically, in a URL generated when > > > > calling Router::url()). > > > > > Let me set out a test scenario, so that I can fully explain what it is > > > > that I am trying to do. In this test scenario, we’ve got a bustling > > > > social networking site. But now, we want to WAP-enable this site - > > > > basically, we’re going to optimise it to be viewed on mobile phones. > > > > However, in order to keep the WAP section separate, we’re going to use > > > > a custom prefix, wap. > > > > > So, as an example URL, if a user wanted to log in to this mobile site, > > > > they would visit /wap/users/login, as opposed to /users/login on the > > > > main site. Additionally, when a user visits /wap, this is the exact > > > > same as visiting /wap/users/login. > > > > > So, we can now set up our first route that would fulfill this > > > > functionality: > > > > > Router::connect('/wap/', array( > > > > 'controller' => 'users', > > > > 'action' => 'login', > > > > 'prefix' => 'wap', > > > > 'wap' => true)); > > > > > This works correctly. However, what happens if I want to link to that > > > > route from a hyperlink contained somewhere in the page? I supply an > > > > array for the URL portion of the HtmlHelper::link() method. So, you > > > > would think that using the following snippet of code, you would be > > > > provided with the correct URL: > > > > > echo $html->link('Foo', array( > > > > 'controller' => 'users', > > > > 'action' => 'login', > > > > 'prefix' => 'wap', > > > > 'wap' => true > > > > )); > > > > > However, this is, unfortunately, not the case. In my experience (using > > > > Cake version 1.2.1.8004), the actual output obtained is something more > > > > along the lines of /users/login/wap:1 - so it seems as if the custom > > > > prefix is being ignored. However, I do believe I might have been able > > > > to pinpoint the bit of code in Cake that prevents the prepending of > > > > this prefix to the URL, as well as a possible solution that I’ve > > > > proposed. > > > > > The code that handles this part of the routing can be found around > > > > line 880 in the Router core library definition: > > > > > $urlOut = Set::filter(array($url['controller'], $url['action'])); > > > > > Now, from what I can make out, this is creating the “front” part of > > > > the URL - the first two sections of the URL. Notice that only the > > > > controller and the action are taken into account. This means that the > > > > custom prefix can never actually come into play, and is always > > > > ignored. The following code snippet is my proposed solution to fix > > > > this: > > > > > if (empty($url['action'])) { > > > > if (empty($url['controller']) || $params['controller'] === $url > > > > ['controller']) { > > > > $url['action'] = $params['action']; > > > > } else { > > > > $url['action'] = 'index'; > > > > }} > > > > > // start additions > > > > $prefix = null; > > > > if(isset($url['prefix']) && isset($url[$url['prefix']]) && $url[$url > > > > ['prefix']] === true) { > > > > $prefix = $url['prefix']; > > > > unset($url[$url['prefix']]);} else { > > > > > $prefix = null;} > > > > > // ... move down to about line 880 > > > > $urlOut = Set::filter(array($prefix, $url['controller'], $url > > > > ['action'])); > > > > // end additions > > > > > Now, I have a few things that I want to ask: > > > > 1. Have you experienced this before? > > > > 2. Have you managed to see any bugs in the code I've posted that I > > > > perhaps missed? > > > > 3. Do you have any objections/queries/comments/opinions on this > > > > modification? > > > > 4. If you feel that this is acceptable, how do I go about submitting > > > > it for inclusion into the Cake core? > > > > > Cheers, > > > > Geoff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---