2010年10月21日星期四

Re: [fw-mvc] Passing Array from One Controller to Another

Flash messenger isn't a bad idea. It's already designed to work within
controllers and has a built-in auto-destroy feature after 1 hop. It also
supports arrays or objects that can be serialized.

So if you're redirecting, the first request would set the data:

$myArray = array(/* ... */);
$this->_helper->flashMessenger->addMessage($myArray);

In the following request you can pull it:

$messages = $this->_helper->flashMessenger->getMessages();
$myArray = $messages[0];

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com

Re: [fw-mvc] Passing Array from One Controller to Another

Alternatively, ignore me as I noticed you want to pass an array.

G

On 21 October 2010 17:57, Gary Hockin <gary@garyhockin.co.uk> wrote:

> Take a look at the Flash Messenger action helper...
>
> http://framework.zend.com/manual/en/zend.controller.actionhelpers.html
>
> Gary/Spabby
>
>
> On 21 October 2010 17:49, Thomas List <thomaslist@hotmail.com> wrote:
>
>>
>> I've been trying to pass an array from one Controller to another without
>> any luck. I've tried to use the Zend_Registry, but when I try to retrieve
>> the value in the next Controller, I get an error "No entry is registered for
>> key 'resultsAdmin'". So how is this done without resorting to redirects and
>> such? I've tried using Zend_Session_Namespace(), but can't find any answers
>> as to how to retrieve the value from the Namespace() once it is set. There
>> has to be a way to create a globalized variable and access it, but how is it
>> done in Zend?
>>
>> Thomas List
>>
>
>
>

Re: [fw-mvc] Passing Array from One Controller to Another

-- Thomas List <thomaslist@hotmail.com> wrote
(on Thursday, 21 October 2010, 12:49 PM -0400):
> I've been trying to pass an array from one Controller to another
> without any luck. I've tried to use the Zend_Registry, but when I try
> to retrieve the value in the next Controller, I get an error "No entry
> is registered for key 'resultsAdmin'". So how is this done without
> resorting to redirects and such? I've tried using
> Zend_Session_Namespace(), but can't find any answers as to how to
> retrieve the value from the Namespace() once it is set. There has to
> be a way to create a globalized variable and access it, but how is it
> done in Zend?

What do you mean by "one controller to another", exactly?

* Are you using _forward() or the ActionStack, and trying to pass data
from one controller to the next using one of these?
* Or are you talking about passing data between requests?

The answers will be different based on how you answer those questions.

In the case of the first, _forward() accepts an array of parameters to
pass as the fourth argument (_forward($action, $controller, $module,
$params)). ActionStack requires you to either update your request object
and pass it (or create a new one and pass that), or use the
actionToStack() method, which has the same signature as _forward().

In the case of the second, you'll need to pass the data using the
session. Zend_Session_Namespace is quite easy:

// Setting the data:
$namespace = new Zend_Session_Namespace('someaction');
$namespace->data = $arrayOfData;

// Retrieving the data:
$namespace = new Zend_Session_Namespace('someaction');
$data = $namespace->data;

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

Re: [fw-mvc] Passing Array from One Controller to Another

Take a look at the Flash Messenger action helper...

http://framework.zend.com/manual/en/zend.controller.actionhelpers.html

Gary/Spabby


On 21 October 2010 17:49, Thomas List <thomaslist@hotmail.com> wrote:

>
> I've been trying to pass an array from one Controller to another without
> any luck. I've tried to use the Zend_Registry, but when I try to retrieve
> the value in the next Controller, I get an error "No entry is registered for
> key 'resultsAdmin'". So how is this done without resorting to redirects and
> such? I've tried using Zend_Session_Namespace(), but can't find any answers
> as to how to retrieve the value from the Namespace() once it is set. There
> has to be a way to create a globalized variable and access it, but how is it
> done in Zend?
>
> Thomas List
>

[fw-mvc] Passing Array from One Controller to Another

I've been trying to pass an array from one Controller to another without any luck. I've tried to use the Zend_Registry, but when I try to retrieve the value in the next Controller, I get an error "No entry is registered for key 'resultsAdmin'". So how is this done without resorting to redirects and such? I've tried using Zend_Session_Namespace(), but can't find any answers as to how to retrieve the value from the Namespace() once it is set. There has to be a way to create a globalized variable and access it, but how is it done in Zend?

Thomas List

2010年10月17日星期日

Re: [fw-mvc] Setting View Script Suffix in Application Config

-- Nick Daugherty <ndaugherty987@gmail.com> wrote
(on Saturday, 16 October 2010, 01:23 PM -0600):
> I have been searching this issue all morning, without success. I cannot
> figure out how to set the view script suffix in a Zend_Application
> configuration file. Basically I'm creating a Zend_Application instance and
> passing in a Zend_Config object as the second param, but my custom view
> suffix does not take effect.
>
> I can change the *layout* suffix no problem, with:
>
> resources.layout.viewSuffix = "php"
>
> but a configuration like:
>
> resources.view.viewSuffix = "php"
>
> OR
>
> resources.view.suffix = "php"
>
> doesn't seem to work. Is there a way to do this from the config file? I know
> that the ViewRenderer Action Helper is where the suffix configuration is
> used...but shouldn't the 'resources.view' configuration parameter affect it?

Currently it doesn't; could you post an issue request, please?

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

2010年10月16日星期六

[fw-mvc] Setting View Script Suffix in Application Config

Hi All,

I have been searching this issue all morning, without success. I cannot
figure out how to set the view script suffix in a Zend_Application
configuration file. Basically I'm creating a Zend_Application instance and
passing in a Zend_Config object as the second param, but my custom view
suffix does not take effect.

I can change the *layout* suffix no problem, with:

resources.layout.viewSuffix = "php"

but a configuration like:

resources.view.viewSuffix = "php"

OR

resources.view.suffix = "php"

doesn't seem to work. Is there a way to do this from the config file? I know
that the ViewRenderer Action Helper is where the suffix configuration is
used...but shouldn't the 'resources.view' configuration parameter affect it?