Tom. Posted May 16, 2016 Share Posted May 16, 2016 // create your hook function function myHook(HookEvent $e) { echo "30 Minutes have passed!"; } // add a hook to your function: wire()->addHook('LazyCron::every30Minutes', null, 'myHook'); I'm trying to use above in my template file, however I'm getting the error: Error: Call to undefined function wire() Any ideas why this isn't working? Edit: $wire->addHook seems to have got it. Is this still correct syntax? Link to comment Share on other sites More sharing options...
AndZyk Posted May 17, 2016 Share Posted May 17, 2016 Hello Tom., personally I never worked with hooks (although it is on my todo list). But I think the addHookMethod in the API reference is related to your question. Available since version 3.0.16. Added as an alias to addHook() for syntactic clarity, previous versions can use addHook() method with same arguments. Regals, Andreas Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 17, 2016 Share Posted May 17, 2016 addHookMethod !== addHook, but wire() is namespaced as ProcessWire/wire() since 3.0. 4 Link to comment Share on other sites More sharing options...
Tom. Posted May 20, 2016 Author Share Posted May 20, 2016 addHookMethod !== addHook, but wire() is namespaced as ProcessWire/wire() since 3.0. I've used $wire->addHook, it seems to be working, however I was just wondering if this was incorrect and that I should use the namespaced wire(). Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 20, 2016 Share Posted May 20, 2016 $wire and ProcessWire/wire() return the exact same object, but $wire is only available in template/bootstrap context. Depending on where you're trying to use wire() it might get compiled and should work as before. 3 Link to comment Share on other sites More sharing options...
ceberlin Posted January 16, 2018 Share Posted January 16, 2018 Just for clarification, the "\" backslash works better: ProcessWire\wire() 1 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