pogidude Posted May 2, 2013 Posted May 2, 2013 Hi, I'm trying to do the following inside a function: function register_styles(){ $url = $config->urls->templates.'styles/'; /** for working with google fonts **/ $fonts = array( 'Source+Sans+Pro:300,400,700', 'Dosis:400,700' ); $styles = array( 'google-fonts' => 'http://fonts.googleapis.com/css?family=' . implode('|', $fonts ) ,'bootstrap' => $url.'bootstrap.css' ,'base' => $url.'base.css' ,'structure' => $url.'structure.css' ,'design' => $url.'design.css' ); return $styles; } but I'm getting an error on this$config->urls->templates.'styles/'"Call to a member function add() on a non-object"thanks for helping
adrian Posted May 2, 2013 Posted May 2, 2013 Due to scope, you need to use wire('config') inside a function. Same is true for all the PW variables:http://processwire.com/api/variables/ If you'll be using it a lot in the function, you can do $config = wire('config') and then use $config as normal after that. 4
pogidude Posted May 2, 2013 Author Posted May 2, 2013 awesome!! thanks! by the way, where do I find a reference for all "wire('config')" and "wire('pages')" thing? or this a convention? $page, $pages, $config equal to wire('var')?
teppo Posted May 2, 2013 Posted May 2, 2013 $page, $pages, $config equal to wire('var')? Yes, $page is same as wire('page') and so on
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now