Friday, October 19, 2012

Re: Using function config() fails to define PHP variables

WHICH config() function are you using?

You might want to see the Configure:: read/write methods or Configure class - loading configuration files.

If you need these only for views, your could maybe use
  $this->set('commonVars', array('something'=>'somethingelse')) 

inside your appController's beforeRender() function and then access these vars from

$commonVars['something']

Inside all of your views.

On Thursday, October 18, 2012 8:23:02 PM UTC+2, glk wrote:
I need the same variables in every view (with a form) and tried using
the config() function to read the file from the Config folder.  It is
read in just fine, and I can generate output from the config file
(e.g. debug($variable)).  However, after the loading of the file, none
of the variables are defined within the view.  In other words, the
$variable is not defined outside of the included file itself.

If I change the use of config() to be an include_once(APP. 'Config' .
DS . 'form_input_params.php') everything works just fine.

What am I missing here?

Thanks in advance for any ideas,

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
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+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: