-- Dmity Sinev <[EMAIL PROTECTED]> wrote
(on Monday, 29 January 2007, 10:58 PM +0200):
> On 29.01.2007, at 22:22, Matthew Weier O'Phinney wrote:
> > -- Waldemar Schott <[EMAIL PROTECTED]> wrote
> > (on Monday, 29 January 2007, 08:46 PM +0100):
> > > I'm not sure, but i think you have to do this:
> > >
> > > echo Zend_Controller_Front::run(YOUR_CONTROLLERS_PATH);
> >
> > Just
> >
> >    Zend_Controller_Front::run($controllerDir);
> >
> > No echo needed.
> 
> I've tried to figure out why it's not working for me just to run  
> Zend_Controller_Front::run($controllerDir); after defining new router.
> That's library/Zend/Controller/Front.php, line 190
> 
>     static public function run($controllerDirectory)
>     {
>         require_once 'Zend/Controller/Router.php';
>         $frontController = self::getInstance();
>         $frontController
>             ->setControllerDirectory($controllerDirectory)
>             ->setRouter(new Zend_Controller_Router())
>             ->dispatch();
>     }
> 
> As I understood, when I'm calling Zend_Controller_Front::run 
> ($controllerDir);  after creating new route it's not use it and just  
> create a new (default) router:
> ->setRouter(new Zend_Controller_Router())

run() is meant for those who want to get up and running quickly, and can
use the default features of the MVC components. If you want to use other
than the default components, use the following:

    $frontController = Zend_Controller_Front::getInstance();
    $frontController->setRouter($router)
        ->setDispatcher($dispatcher); // or whatever options you need to set
    $frontController->dispatch();

Here's the rule of thumb: If you're using anything other than default
components, or need to set options or configure any of the components,
don't use run(); instead call dispatch() on a front controller instance.

> > > AFAIK the default behaviour is, that the dispatch() method only  
> > > returns
> > > the output without echoing.
> >
> > Default behaviour is to render the response from dispatch().
> >
> > > It's possible to call Zend_Controller_Front::returnResponse(true); or
> > > something like this.
> >
> > Doing this prevents dispatch() from rendering the response, and  
> > returns
> > the response object, which you can then manipulate prior to rendering.
> > If you do this, you can't use run(), but must use dispatch() instead.
> >
> > > Dmity Sinev schrieb:
> > > > Hi!
> > > >
> > > > You can do this by defining your own route for example like this:
> > > >
> > > > $router = new Zend_Controller_RewriteRouter();
> > > >
> > > > $router->addRoute(
> > > > 'default',
> > > > new Zend_Controller_Router_Route(':action/:subnavi/',
> > > > array('controller' => 'YourDefaultController' , 'action' =>
> > > > 'YourDefaultAction', 'subnavi' => 'YourDefaultSubnavi'))
> > > > );
> > > >
> > > > $front->setRouter($router);
> > > >
> > > > // Instead this 2 lines should be just
> > > > Zend_Controller_Front::run(PATH_YOUR_CONTROLLERS), but it's not
> > > > working.... why?
> > > > $front->setControllerDirectory(PATH_YOUR_CONTROLLERS);
> > > > $front->dispatch();
> > > >
> > > > Now, when you request this url http://www.example.org/mainnavi/ 
> > > > subnavi
> > > > you will get:
> > > > controller = YourDefaultController
> > > > action = mainnavi
> > > > subnavi = subnavi
> > > >
> > > > This approach is suitable only for very small sites...
> > > >
> > > > For more information please read this:
> > > > http://framework.zend.com/manual/en/ 
> > > > zend.controller.providedsubclasses.html#zend.controller.providedsubc 
> > > > lasses.rewriterouter
> > > >
> > > >
> > > > On 29.01.2007, at 17:37, Ivan Ruiz Gallego wrote:
> > > >
> > > > > Hello,
> > > > >
> > > > > This is my very simple question:
> > > > > I would like to route URL's like
> > > > > "http://www.example.org/mainnavi/subnavi"; to a single controller  
> > > > > that
> > > > > renders the appropriate content depending on "mainnavi" and
> > > > > "subnavi". I would like to avoid writing one controller for each  
> > > > > main
> > > > > navigation point. Which is the appropriate way to do this within  
> > > > > Zend
> > > > > Framework? Or do you think that the whole approach is  
> > > > > unappropriate?
> > > > > Thank you.

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

Reply via email to