Jump to content

Mathroth

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by Mathroth

  1. public function myHook(HookEvent $e) { $seconds = $e->arguments[0]; $this->syncMobileDE($e); echo "30 seconds have passed!"; } Changed it with the argument. Unfortunately the function doesn't execute. The "echo" is displayed on every page. So the error might be in the syncMobileDE() Function. I also use the function with a hook on "Pages::save" and there it works. public function init() { ... $this->pages->addHookAfter('Pages::save', $this, 'syncMobileDE'); }
  2. hello to all processwire dudes... I need your help again As you can see in my code i want to call a simple function i the processwire lazy cron hook. Lazy cron works and execute the "echo 30 seconds have passed!" But the function syncMobileDE(); does not return any results. Thanks for your advises! public function init() { $this->addHook('LazyCron::every30Seconds', $this, 'myHook'); } public function myHook(HookEvent $e) { $seconds = $e->arguments[0]; echo "30 seconds have passed!"; $this->syncMobileDE(); } public function syncMobileDE($event) { /** @var Page $page */ $page = $event->arguments(0); if($page->template->name == 'fahrzeugangebot') { $this->listCars(); $this->initDetail(); $this->message("Mobile.de synchronisiert"); } }
  3. You made my day, now it works. Looks very logical and works quite well. Thanks to all for your advises. Have a nice weekend!
  4. Unfortunately not! It just works if I save any of the pages – regardless which template the page is using. public function init() { $this->pages->addHookAfter('Pages::save', $this, 'syncMobileDE'); }
  5. public function ready() { if($this->page->template->name == 'TemplateName') { $this->addHookAfter('save', $this, 'syncMobileDE'); } } Also tried this. No function execution
  6. Thanks for your help! Seems to be the right syntax now but unfortunately the function will not be fired. I also tried different templates...
  7. Greetings to all processwire fans, I am new in processwire and I have used it since 3 weeks. Probably it's a really silly question but does someone now how I can execute a function in my own module, which is triggered when I save a pages, which contains a user-defined template. I tried to to this with an basic if/else condition to trigger the hook when the page has theTemplateName== "". Unfortunately it doesn't work. So I try this which might be the wrong Syntax. Perhaps someone can give me a hint THANKS a lot! public function init() { // add a hook after the $pages->save, to issue a notice every time a page is saved $this->page->template == "templateName"->addHookAfter('save', $this, 'example1'); }
×
×
  • Create New...