-- [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote
(on Thursday, 25 January 2007, 01:00 PM +0100):
> i was also looking for such functionnality, plus, i wanted that particular
> action could be called in a view context.
> As it is not seems to be (yet ?) included, here is my temporary solution :
> 
> let's define a "Widget.php" helper :
> 
> class Zend_View_Helper_Widget
> {
>       public function Widget($module=NULL, $controller=NULL, $action=NULL)
>       {
>               Zend::loadClass('Zend_Controller_Request_Http');
>               $Request = new Zend_Controller_Request_Http();
>               $Request->setModuleName($module);
>               $Request->setControllerName($controller);
>               $Request->setActionName($action);
> 
>               $controller = Zend_Controller_Front::getInstance();
>               $controller->dispatch($Request);
>       }
> }

I wouldn't do it this way. First off, you're possibly altering the state
of the current front controller instance and response object, which
could lead to unintended consequences. All you need is the dispatcher in
this case -- you've already set the module, controller, and action.
Change the internals to this:

    $response   = new Zend_Controller_Response_Http();
    $dispatcher = new Zend_Controller_Dispatcher();
    $dispatcher->dispatch($Request, $response);
    return (string) $response;

(You need a response object to pass to the dispatcher's dispatch
method. Alternatively, you could subclass the dispatcher and provided a
convenience method that creates the response object and returns the
rendered output.)

I'll reply to the OP in a separate response; it's pretty easy to
implement partials using Zend_View.

> (Note : contrary to the reference manual, custom helpers MUST begin by
> "Zend_View_Helper". Is it a bug ?)

The test suite indicates that you should be able to prefix helpers with
your own class prefix. You can do so with the following construct:

    $view->addHelperPath($path, $classPrefix);

If this doesn't work for you, please report the issue on JIRA with the
minimum amount of code required to show it doesn't work.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to