@miles helpers can still use functionalities of other helpers so thats not really an excuse but if it works, ok
On 17 Dez., 22:15, Miles J <[email protected]> wrote: > @euromark - He answered that in his post. > > @ojonam - Scope issure for sure, just do. > > function getLink($view, $x) { > return $view->Html->link($x,"#".$x); > > } > > echo getLink($this, $x); > > On Dec 17, 4:47 am, euromark <[email protected]> wrote: > > > > > > > > > is there a reason why you dont want to stick to the cake pattern > > and create helpers for that? > > > On 17 Dez., 13:41, Ryan Schmidt <[email protected]> wrote: > > > > On Dec 17, 2010, at 05:15, ojonam wrote: > > > > > $getLink = function($x){return $this->Html->link($x, '#'.$x);}; > > > > $alphabet = array_map($getLink, array_merge(range('a','z'))); > > > > In PHP 6.x or possibly 5.4.x you should be able to do this: > > > > $getLink = function($x)use($this){return $this->Html->link($x, '#'.$x);}; > > > $alphabet = array_map($getLink, array_merge(range('a','z'))); > > > > However, it's not possible for an anonymous function to use "$this" in > > > PHP 5.3.x; see this bug report: > > > >http://bugs.php.net/bug.php?id=49543 > > > > Until then, you have to copy $this to a temporary variable; here, I copy > > > it to "$view": > > > > $view = $this; > > > $getLink = function($x)use($view){return $view->Html->link($x, '#'.$x);}; > > > $alphabet = array_map($getLink, array_merge(range('a','z'))); 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
