I seemed to resolve issue #1 in my last post (thanks again to ADmad
for prompting me to look through the nightly build's test cases for
this).
v1.2: Router::connect('/:subdirectory/:controller/:action/*', array(),
array('subdirectory' => '[a-zA-Z0-9\-]+'));
Now my URL's can be prefixed with anything that matches that regex and
the prefix will be available in the view as $this->params
['subdirectory']. If I form my $html->links as:
$html->link('Link Name', array('controller' => 'locations', 'action'
=> 'view', 'subdirectory' => $this->params['subdirectory']));
...then Cake will automatically keep the prefix in the generated URL.
Now I just need to figure out how to utilize my other "alias" routes
to fall inside this dynamic prefix routing (see my #2 above). I've
tried moving the "subdirectory" route to the top and bottom of the
routes list but had the same results with it.
On Jan 7, 2:34 pm, etipaced <[email protected]> wrote:
> Thanks to ADmad from the IRC channel for this solution:
>
> v1.1: $Route->connect('/sub1/:controller/:action/*', array());
> v1.2: Router::connect('/sub1/:controller/:action/*', array());
>
> There are just 2 downsides to this which I am still trying to resolve:
>
> 1. How can I dynamically add in these routes so an admin can (via the
> web interface) add a new sub-directory and theroutingwill
> automatically behave properly? I tried /*/:controller/:action/* but
> had no luck.
>
> 2. How can I preserve my existing custom routes without re-creating
> them for each sub-directory? For instance, I have $Route->connect('/
> news', array('controller' => 'articles', 'action' => 'index')). But as
> I (dynamically) add new sub-directories, I want each sub-directory to
> utilize this route, too. In other words, adding a new sub-dir should
> allow for /sub3/news without having to manually add it.
>
> On Jan 7, 12:17 pm, etipaced <[email protected]> wrote:
>
> > I have an application (built in 1.1, though may get upgraded to 1.2 if
> > it helps my situation) that needs an additionalprefixroute added to
> > it. For example, see the 1.2 manual entry
> > here:http://book.cakephp.org/view/544/Prefix-Routing
>
> > My application already has adminrouting, but I now need to move all
> > the public (or non-admin routed) pages to a sub-directory (call it
> > "sub1"), and add an additional sub-directory as well (call it "sub2").
>
> > My dilemma is that I need sub1 and sub2 to use the exact same
> > controller functions instead of having their own. Normally when using
> > prefixing, you write a function to correspond with the specificprefix
> > in use. For example,www.website.com/admin/users/edit/3wouldactually
> > call UsersController::admin_edit(). Likewise in the manual entry I
> > linked to above and for my hypothetical example the
> > URLwww.website.com/sub1/locations/view/3wouldcall
> > LocationsController::sub1_view(). This is a problem for me because I
> > really want that URL to call LocationsController::view() instead. I
> > also needwww.website.com/sub2/locations/view/3tocall
> > LocationsController::view() as well.
>
> > I plan to set session data in AppController to distinguish which sub-
> > directory (sub1 or sub2) the current user is in. That value will then
> > affect my model queries.
>
> > The further issue is that additional sub-directories (which are
> > essentially instance copies of the application) will need to be
> > dynamically added via the admin interface as well. This is why I want
> > to handle the situation with a mod_rewrite customization or with
> > Cake'srouting.
>
> > Any help or assistance is greatly appreciated! I'm also on IRC as
> > etipaced. Thank you for reading :)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---