pogidude Posted May 2, 2013 Share 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 Link to comment Share on other sites More sharing options...
adrian Posted May 2, 2013 Share 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 Link to comment Share on other sites More sharing options...
pogidude Posted May 2, 2013 Author Share 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')? Link to comment Share on other sites More sharing options...
teppo Posted May 2, 2013 Share Posted May 2, 2013 $page, $pages, $config equal to wire('var')? Yes, $page is same as wire('page') and so on Link to comment Share on other sites More sharing options...
deh3nne Posted March 15, 2014 Share Posted March 15, 2014 Thank You - That Information helped me out Link to comment Share on other sites More sharing options...
Martijn Geerts Posted March 16, 2014 Share Posted March 16, 2014 @deh3nne: Welcome ! Link to comment Share on other sites More sharing options...
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