On Tue, Jul 20, 2010 at 2:18 AM, nicky <[email protected]> wrote:
> hii i m developing a project in cake where i want some words to come
> before controllers name like as http://www.abc.com/teama/users
> http://www.abc.com/teamb/users
>
> Can it is possible i have nothing to do with this word team a and team
> b just for displaying .
Router::connect(
'/:team/users/:action',
array('controller' => 'users'),
array('team' => 'team[a-z]')
);
function index()
{
die(debug($this->params));
}
You should see that there's a value for $this->params['team'] that is
passed. In your code, you should do:
if (isset($this->params['team']) && !empty($this->params['team']))
{
$team = $this->params['team'];
...
}
You can also 'pass' the value:
Router::connect(
'/:team/users/:action',
array('controller' => 'users'),
array('team' => 'team[a-z]', 'pass' => array('team'))
);
function index($team = null)
{
debug($team);
die(debug($this->params));
}
Passing the value allows you to do:
if (!isnull($team))
{
...
}
However, you'd need to add "$team = null" to all your methods. If you
only need to pass the team for the index method:
Router::connect(
'/:team/users',
array('controller' => 'users', 'action' => 'index'),
array('team' => 'team[a-z]', 'pass' => array('team'))
);
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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