Jonathan Lahijani Posted October 25, 2019 Posted October 25, 2019 <?php namespace ProcessWire; class MyCoolModule extends WireData implements Module, ConfigurableModule { public function __construct() { $this->myvar = $this->wire('pages')->get(2)->name; // problematic for some reason } I have the above code in my module. However it throws this error: Fatal error: Uncaught Error: Call to a member function get() on null. Why is this the case?
gmclelland Posted November 5, 2019 Posted November 5, 2019 Could you replacing the line with this: $this->myvar = $this->pages->get(2)->name; // problematic for some reason I have a note in my Processwire notes that say's --Extend WireData to access API variables using $this->page instead of calling wire() function every time. It also lets us get module settings directly using $this->someSetting.
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