I'm not sure if this is best practice, but I generally put put
recurring variables into the beforeRender() method in your controller
(or app_controller). That way you'll have at least a default value for
your element (if it needs it). If it doesn't, then doing the check in
the element should suffice.

On Feb 23, 9:27 pm, Jeremy Burns <jeremybu...@me.com> wrote:
> if (isset($variable)):
>    do something;
> else:
>    don't;
> endif;
>
> Jeremy Burns
> jeremybu...@me.com
> (Skype) +44 208 123 3822 (jeremy_burns)
> (m) +44 7973 481949
> (h) +44 208 530 7573
>
> On 23 Feb 2010, at 12:49, jbov wrote:
>
>
>
>
>
> > I am a bit of newbie with CakePHP and DB-driven sites so bear with me.
>
> > I have an element that I am displaying on every page, and I am passing
> > one variable to it from every controller function.  If I do not pass
> > the variable I get an ugly unknown variable error.
>
> > I want to ease the requirement of passing the variable by not
> > displaying the relevant HTML from the element if the variable has not
> > been passed (avoiding the ugly unknown variable error).
>
> > Where would the logic for this go?  My best guess is the
> > AppController.  Second guess is creating a component for this. What's
> > the right thing to do?
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups 
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to