Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Please help me understand URL and Routes in Cake
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
John  
View profile   Translate to Translated (View Original)
 More options 28 Feb 2007, 20:13
From: "John" <johnsv...@googlemail.com>
Date: Wed, 28 Feb 2007 12:13:58 -0800
Local: Wed 28 Feb 2007 20:13
Subject: Re: Please help me understand URL and Routes in Cake

> So, I'd like to have the following URLs
> /units    - for a view showing a table of multiple units
> /units/<unit name>    - for a view of the single unit (no, I don't
> want to use the action in the URL like /units/view/<unit name>, I'd
> like to keep this one as short and simple as possible)

I wanted to do something similar, but rather than using routes I put a
condition in the beforeFilter of a controller. The controller is
called galleries, I wanted to keep the actions like index, view,
detail, etc. So I could have /galleries/view/<gallery id> but also to
have /galleries/<region name>

Anyway I've got the following in my controller

var $regions = array('london', 'south_west', 'north', 'south_east',
'central', 'wales', 'scotland', 'northern_ireland');

function beforeFilter()
{
if(in_array($this->action, $this->regions))
  {
     $this->region();
     exit;
  }

}

So if the is a URL like /galleries/london it will route to the the
action region() in the controller.

It works well, but I was wondering if there are better solutions?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google