Re: getting data from ClassRegistry

2007-04-17 Thread gwoo

While you may be using the correct method to access the vars, you have
to ask yourself why. If you tie a helper to a specific set a of data
it is not as reusuable. That said, I can see the scenario where you
have a component that handles some nifty stuff and then passes it to
the view. In this case, I have uses $this->params which is available
in the helpers. In the beforeRender() helper method of 1.2 you can
change use those params before the helper is used. We had talked for a
while about a startup() method in the helper that could receive the
viewVars, but at the end of the day, the situations when you should
use something like this are on the edges at best.

I trust you will use this power wisely young padawan. May the Cake be
with you.


--~--~-~--~~~---~--~~
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: getting data from ClassRegistry

2007-04-17 Thread Copongcopong

Thanks for your reply, I did do the same suggested code. My other
question is, if this is a bad practice, since I am doing this code
inside a helper. Thanks.

On Apr 18, 1:35 am, "Mariano Iglesias" <[EMAIL PROTECTED]>
wrote:
> Further on nate's comment:
>
> $vars = array();
>
> $view =& ClassRegistry::getObject('view');
> $viewVars = $view->getVars();
>
> foreach($viewVars as $var) {
> $vars[$var] = $view->getVar($var);
>
> }
>
> And 'vars' is now an indexed array with your view vars.
>
> -MI
>
> ---
>
> Remember, smart coders answer ten questions for every question they ask.
> So be smart, be cool, and share your knowledge.
>
> BAKE ON!
>
> blog:http://www.MarianoIglesias.com.ar
>
> -Mensaje original-
> De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
> de nate
> Enviado el: Martes, 17 de Abril de 2007 12:37 p.m.
> Para: Cake PHP
> Asunto: Re: getting data from ClassRegistry
>
> If on Cake 1.2:
>
> $view =& ClassRegistry::getObject("view");
> $vars = $view->getVars();


--~--~-~--~~~---~--~~
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: getting data from ClassRegistry

2007-04-17 Thread Mariano Iglesias

Further on nate's comment:

$vars = array();

$view =& ClassRegistry::getObject('view');
$viewVars = $view->getVars();

foreach($viewVars as $var) {
$vars[$var] = $view->getVar($var);
}

And 'vars' is now an indexed array with your view vars.

-MI

---

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 

BAKE ON!

blog: http://www.MarianoIglesias.com.ar


-Mensaje original-
De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
de nate
Enviado el: Martes, 17 de Abril de 2007 12:37 p.m.
Para: Cake PHP
Asunto: Re: getting data from ClassRegistry

If on Cake 1.2:

$view =& ClassRegistry::getObject("view");
$vars = $view->getVars();


--~--~-~--~~~---~--~~
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: getting data from ClassRegistry

2007-04-17 Thread nate

If on Cake 1.2:

$view =& ClassRegistry::getObject("view");
$vars = $view->getVars();

On Apr 17, 7:47 am, Copongcopong <[EMAIL PROTECTED]> wrote:
> Any consequence(s) of getting viewVars from ClassRegistry? I am trying
> to get some data in viewVars to be initialize for my helper.
>
> Any better way (or best practice) to accomplish this? The main goal is
> to have my viewVars, that were loaded using
> AppController::beforeRender(),  be accessible by my Helper.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---