Wednesday, September 28, 2011

Re: Html helper - stop adding prefix unless explicitly specified

i use a custom app helper method i called defaultLink() which resets
all prefixes unless specified.
although thats maybe not exactly what you have in mind
but you could make sth similar with your own default values

either way - called via
$this->Html->defaultLink();
in any view as always

On 28 Sep., 15:53, nowotny <nowotn...@gmail.com> wrote:
> Hello.
>
> Let's say you have a menu in the layout that should be constant
> throughout the whole site with the following links:
> $this->Html->link('Posts',array('controller'=>'posts','action'=>'index'));
> $this->Html-
> >link('Users',array('controller'=>'users','action'=>'index',
>
> 'admin'=>true));
>
> If you're in e.g.www.domain.com/pages/indexthose two links point to:www.domain.com/postswww.domain.com/admin/users
>
> And that's OK. But when you're in a prefixed route, e.g.www.domain.com/admin/tags/index, all the links are prefixed:www.domain.com/admin/posts(<- wrong)www.domain.com/admin/users
>
> I know I could add 'admin'=>false to all links that should not be
> prefixed but that's not really a feasible solution.
>
> So here comes my question: is there a way for Html helper not to add
> prefixes to links in prefixed routes unless when I explicitly set it
> to do so with 'admin'=>true?
>
> I think it should be possible by defining a route but I was not
> successful in setting one up correctly.
>
> BTW: I'm using CakePHP 1.3.12

--
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: