Hmm,
The harder method is harder than it looks. When I type domain.com/_preview,
the default router thinks its a controller and returns an error.
domain.com/default/index/index/_preview works as expected.
Waigani wrote:
>
> Thank you very much Matthew.
>
>
> Matthew Weier O'Phinney-3 wrote:
>>
>> -- Waigani <[EMAIL PROTECTED]> wrote
>> (on Wednesday, 03 October 2007, 01:11 AM -0700):
>>> I'm still struggling with the router. Here is the idea. On any page you
>>> type
>>> /_preview after the uri to see the cms preview of that page. Here is the
>>> code:
>>>
>>> $ctrl = Zend_Controller_Front::getInstance();
>>> $router = $ctrl->getRouter();
>>> $router->addRoute('cms', new
>>> Zend_Controller_Router_Route('*/:_preview',
>>
>> I can tell you already that the above won't work; wildcards in routes
>> are greedy, meaning they eat everything remaining in the URL.
>>
>>> array('cmsPreview' => 'true')));
>>>
>>> I've put this in a routeStartup plugin.
>>>
>>> This works fine EXCEPT, the cms uses the default module, controller and
>>> action params which have been wiped by the new router. I see that the
>>> default router users Zend_Controller_Router_Route_Module. Is there a way
>>> to
>>> tack on the above logic (*/:_preview = 'cmsPreview' => 'true') to the
>>> default router? The main thing is keeping the default params (which is
>>> the
>>> same problem as in my earlier posts).
>>
>> You have two options:
>>
>> * Simplest: Just use a $_GET param for this:
>>
>> http://example/foo/bar?cmsPreview=1
>>
>> * Harder: In a routeStartup() plugin, grab the PATH_INFO from the
>> request object, and check for '_preview' being the last portion of
>> the path. If so, set the cmsPreview parameter in the request object,
>> and strip that out of the PATH_INFO:
>>
>> $request = $this->getRequest();
>> $path = $request->getPathInfo();
>> if ('_preview' == substr($path, -8)) {
>> $request->setParam('cmsPreview', true);
>> $path = substr($path, 0, strlen($path) - 9);
>> $request->setPathInfo($path);
>> }
>>
>>> Waigani wrote:
>>> >
>>> > It is for a login form which logs you into the current page. So I'm
>>> > actually after module, controller action names. I'll just do it as a
>>> > plugin.
>>> >
>>> >
>>> >
>>> > Leo Büttiker wrote:
>>> >>
>>> >> Ohh, I'm sorry I didn't read the hole thread. For getModuleName you
>>> have
>>> >> to
>>> >> probably do it in a plugin in the routeShutdown() methode. But why do
>>> you
>>> >> need the modulname there? You can access to it in the controller
>>> anyway.
>>> >>
>>> >> -----Ursprüngliche Nachricht-----
>>> >> Von: Waigani [mailto:[EMAIL PROTECTED]
>>> >> Gesendet: Montag, 1. Oktober 2007 11:04
>>> >> An: [email protected]
>>> >> Betreff: Re: [fw-general] AW: getRequest
>>> >>
>>> >>
>>> >> So how do you do it in the bootstrap? I'm guessing you getModuleName
>>> >> after
>>> >> $front->dispatch()?
>>> >>
>>> >>
>>> >>
>>> >>
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/getRequest-tf4531440s16154.html#a13014626
>>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>>
>>
>> --
>> Matthew Weier O'Phinney
>> PHP Developer | [EMAIL PROTECTED]
>> Zend - The PHP Company | http://www.zend.com/
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/getRequest-tf4531440s16154.html#a13027440
Sent from the Zend Framework mailing list archive at Nabble.com.