Gazley Posted March 26, 2014 Share Posted March 26, 2014 Hi, Repurposed this question as no takers in the module forum. I created a simple autoload module. It is definitely loaded at page instantiation time - I step through its init() call in the debugger. However, when it is referenced later, wire('ModuleName') returns null. I can however reference it using $modules->get('ModuleName') Any ideas why this might be the case? Thanks. Link to comment Share on other sites More sharing options...
Soma Posted March 26, 2014 Share Posted March 26, 2014 Wire holds the api vars not a module. Like wire('pages') etc. You get or load the module with $mymodule = wire('modules')->get('ModuleName'); Or same $mymodule = wire('modules')->ModuleName; Or on templates $mymodule = $modules->ModuleName; What you have is correct, but get or load a module will load it explicit whether autoload or not. It will even install the module if it's not. Where not doing a call via API, an autoload module will get loaded still. So you dont need to or cant check to see if the module is loaded, at least I haven't been able to. 2 Link to comment Share on other sites More sharing options...
adrian Posted March 26, 2014 Share Posted March 26, 2014 I know this is a post that Soma started on this topic, but I still think it is relevant to link to here since we got into talking about checking to see if a module is loaded or not: https://processwire.com/talk/topic/5477-check-if-a-module-is-loaded/ 2 Link to comment Share on other sites More sharing options...
Gazley Posted March 27, 2014 Author Share Posted March 27, 2014 Thanks Guys. I appreciate your clarification around the concept of "autoload" 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