Saturday, September 25, 2010

Re: $this->params['named'] is empty

its not that difficult, man^^

function register() {
if (!empty($this->params['named']['abort'])) { # here you can see
that abort:1 would delete the session content
$this->Session->delete('Auth.Tmp');
$this->redirect(array('action' => 'login'));
}
...
}

just put pr($this->params); inside your action and you will see how it
works


On 25 Sep., 15:19, Sarpidon <epap...@gmail.com> wrote:
> Can someone give me an example. I just cannot make it work.
>
> Category Controller:
> public function view() {}
>
> Routes:
> Router::connectNamed(array('alias'));
>
> url
> /categories/view/alias:something
>
> $this->params['named'] comes up empty ...
>
> On Sep 25, 12:19 am, Miles J <mileswjohn...@gmail.com> wrote:
>
>
>
> > Because you are not passing them as named params, you are passing them
> > as method arguments.
>
> > public function view($category) { }
>
> > On Sep 24, 7:17 am, Sarpidon <epap...@gmail.com> wrote:
>
> > > Hi. I am not sure what I am doing wrong but even though I am using
> > > named params $this->params['named'] always shows up as empty.
>
> > > Routes
> > > Router::connect('/news/:category', array('controller' => 'categories',
> > > 'action' => 'view'), array('pass' => array('category')));
>
> > > View
> > > echo $html->link($link['name'], array('controller' => 'categories',
> > > 'action' => 'view', 'category' => $link['alias']));
>
> > > pr($this->params)
> > >     [category] => europe
> > >     [named] => Array
> > >         (
> > >         )
>
> > >     [pass] => Array
> > >         (
> > >             [0] => greece
> > >         )
>
> > > I also tried
> > > Router::connectNamed(array('category'));
> > > Router::connect('/news/:category', array('controller' => 'categories',
> > > 'action' => 'view'), array('pass' => array('category')));
>
> > > and
> > > Router::connectNamed(array('category'));
> > > Router::connect('/news/*, array('controller' => 'categories', 'action'
> > > => 'view'));
>
> > > no success....
>
> > > any help?

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: