Saturday, December 31, 2011

Re: get current url as array

I am talking about the complete array to be passed to Html::url() /
Html::link()
of course there are tons of ways to get the data itself
just saw today: Router::parse($this->request->here(false));
besides 10 other ways.

but you would either have to manually join them:
array('controller'=>$this->params['controller'], ...)
or you would have to merge or unset a lot of stuff from it (see above
example with Router::getParams(true);)

out of the box we can only retrieve the final string (in the view
layer with Html::url()) - which is unfortunate in an environment where
every url is usually array-based...

On 31 Dez., 13:04, mike karthauser <mi...@brightstorm.co.uk> wrote:
> You should be able to get the data you need in $this->params.
>
> Mike Karthauser
> Brightstorm limited
> Tel: 07939252144
>
> On 31 Dec 2011, at 12:01, euromark <dereurom...@googlemail.com> wrote:
>
>
>
>
>
>
>
> > any feedback?
> > seems like this is a missing functionality.
>
> > example:
> > admin/authplugin/users/edit/2
>
> > I would expect to find some router method to get
>
> > $url = array(
> >    'admin' => 1
> >    'plugin' => 'authplugin'
> >    'controller' => 'users'
> >    'action' => 'edit'
> >    2
> > )
> > for example
> > maybe with Router::urlAsArray()
> > which would be similar to the result of Router::parse() but it already
> > contains the passed and named params as expected
> > to easily adjust it before passing it to Html::url() or Html::link():
>
> > $url[#] = 'somehash';
> > or
> > $url[] = 'somepassedparam';
> > or
> > $url['key'] = 'somenamedparam';
>
> > echo $this->Html->link('Title', $url);
>
> > On 28 Dez., 21:59, euromark <dereurom...@googlemail.com> wrote:
> >> ...or for any url for that matter (for adding some named/pass params
> >> etc)
>
> >> PS: I forgot
> >>         if (isset($urlParams['prefix'])) {
> >>                 unset($urlParams['prefix']);
> >>         }
>
> >> On 28 Dez., 21:04, euromark <dereurom...@googlemail.com> wrote:
>
> >>> am I missing sth or is there no url() method etc for returning the
> >>> current url as array?
> >>> I only know this way:
>
> >>>                 $urlParams = Router::getParams(true);
> >>>                 $urlParams = am($urlParams, $urlParams['named'],
> >>> $urlParams['pass']);
> >>>                 unset($urlParams['named']);
> >>>                 unset($urlParams['pass']);
>
> >>> but it seems a little bit like overhead...
> >>> does anyone know how to do that easier?
> >>> maybe we should introduce Router::urlAsArray()
> >>> with default NULL => return current ?
>
> > --
> > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

No comments: