Jump to content

Autload module not discovered by wire('ModuleName')


Gazley
 Share

Recommended Posts

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

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.

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...