Re: Can a Custom Helper render an element?
just in case someone stumbles by this thread with a similar issue: you have to have return $View->element("editor/$name"); if your view call is like echo $myHelper->displayControl($name); OR function displayControl($name) { $View =& ClassRegistry::getObject('view'); echo $View->element("editor/$name"); } And I'm up and running, thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Can a Custom Helper render an element?
It is possible quite easily. The reason your attempt failed is that View::element internally calls View::renderElement via the $this variable, which [because you're calling it statically from within the helper] is resolved to the helper. Just get a reference to the view object: class BreakfastHelper extends AppHelper { function eggs() { $View =& ClassRegistry::getObject('view'); $View->element('bacon'); } } Note that you don't need to add the extension to element() or renderElement(), it is handled automatically. On Mar 27, 3:40 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Again, this strikes me as devastatingly simple. Again, I've searched > through docs and manuals to no avail. > > I want > class EditorHelper extends Helper > ... > function displayControl($name) { > //set a bunch of stuff then > $this->element("editor/$name".".thtml"); > } > > but, obviously, there's no Helper::element method so i also try > View::element("editor/$name".".thtml"); > > which yields: > Method EditorHelper::renderElement does not exist [CORE/cake/libs/view/ > helper.php, line 148] > > so the element() method is doing a $this->renderElement... > > so it's starting to look like this just isn't possible? > > is there somewhere else that reusable elements should be put if you're > going to use helpers rather than views to display them? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Can a Custom Helper render an element?
Again, this strikes me as devastatingly simple. Again, I've searched through docs and manuals to no avail. I want class EditorHelper extends Helper ... function displayControl($name) { //set a bunch of stuff then $this->element("editor/$name".".thtml"); } but, obviously, there's no Helper::element method so i also try View::element("editor/$name".".thtml"); which yields: Method EditorHelper::renderElement does not exist [CORE/cake/libs/view/ helper.php, line 148] so the element() method is doing a $this->renderElement... so it's starting to look like this just isn't possible? is there somewhere else that reusable elements should be put if you're going to use helpers rather than views to display them? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---