bernhard Posted January 19, 2016 Share Posted January 19, 2016 if you want to get access to eg $pages in modules you have to do something like $pages = wire('pages'); sometimes i see people using $this->wire('pages') like here for example: https://processwire.com/talk/topic/11939-make-dashboard-plugin-page-the-default-admin-page/?p=111017 is there any difference in those two methods? i also saw $this->user->name and i was not sure if that would work inside a module because i thought it should be wire('user')->name thank you in advance Link to comment Share on other sites More sharing options...
adrian Posted January 19, 2016 Share Posted January 19, 2016 In some cases it doesn't matter, and in some cases it does It depends on the scope and class context as to whether $this->user->name will work or not, but seems to have been common practice in various modules. With PW 3.x ramping up I would suggest reading this: https://processwire.com/blog/posts/processwire-2.6.21-upgrades-comments-more-on-pw-3.x/#more-updates-on-processwire-3.0 - scroll down a little to the "Multi-instance with 3rd party modules and PW 3.x" section where it explains what works where. Actually this is a good reminder for me to update my modules to use $this->wire() 6 Link to comment Share on other sites More sharing options...
bernhard Posted January 19, 2016 Author Share Posted January 19, 2016 Thank you Adrian. Seems that the blog post came 3 months too early for me. I read it but didn't remember. Now it makes sense 1 Link to comment Share on other sites More sharing options...
Recommended Posts