Stefanowitsch Posted January 20, 2019 Share Posted January 20, 2019 Hello! I am using the _init.php file to place different php functions to render something on the page. For example a gallery, or a teaser group. I can then just call the function within a page template and the function renders the HTML code with the data given. Right now I want to render some teasers but I need to have access to the $modules variable which is not working right now. I get an undefined variable error. How can I use the $module variable in a different environment than a template file? Link to comment Share on other sites More sharing options...
kongondo Posted January 20, 2019 Share Posted January 20, 2019 (edited) 26 minutes ago, Stefanowitsch said: Right now I want to render some teasers but I need to have access to the $modules variable which is not working right now. I get an undefined variable error. You are getting hit by a variables scope issue. You cannot use global variables like $modules directly inside a function. Instead, use this (there are other variants - see the new docs here) wire('modules'); Edited January 20, 2019 by kongondo 4 Link to comment Share on other sites More sharing options...
Stefanowitsch Posted January 20, 2019 Author Share Posted January 20, 2019 Cool. Using this instead of $modules works. wire('modules') 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