Jump to content

Search the Community

Showing results for tags 'lazycron'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 9 results

  1. Hi all, I have noticed that LazyCorn seems to run maybe once or twice and then just stops. Has anybody else encountered this, I have the following within 2 different modules. public function init(){ $this->addHookAfter('ProcessModule::executeEdit', $this, 'configurableButtons'); wire()->addHook('LazyCron::every15Minutes', $this, 'autoGenerate'); } public function init(){ wire('forms')->addHookAfter('ProcessModule::executeEdit', $this, 'configurableButtons'); wire()->addHook('LazyCron::everyHour', $this, 'getExport'); } Does having multiple LazyCrons setup cause any issues?
  2. LazyCron operates on an elapsed time interval, but you may want it to operate at specified times. Assuming your website is going to be visited sufficiently frequently (either by real users or by a Cron job), you can do this by editing the file /assets/cache/LazyCron.cache. This file contains 21 timestamps – one for each of the LazyCron specified intervals (e.g. “everyMinute”). The timestamp denotes when that interval was last triggered. To make the trigger happen at the required time, change the timestamp in the matching row to be when the previous trigger should have occurred. To make this easier, I have done an Excel spreadsheet (“Lazycron_fill.xlsx”) to simplify the process – just enter the required benchmark timings and copy the result into the LazyCron.cache file. Lazycron_fill.xlsx
  3. I'd like to set up a LazyCron function that fires every hour on each page that has a template named "post". So far I have gotten the function running. But when it has fired once on "Page with Title A", it takes and hour before it is fired again on any other pages. It makes sense, hooking the function with wire()->addHook(). What I want to do, is to get the function to be fired with LazyCron individually for each page. So that "Page with Title A" fires every hour (if it has pageviews), and "Page with Title B" is fired individually and possibly during the same timeline, if it has pageviews. Is this possible? Or might there be another way to utilize a sort of LazyCron on individual pages?
  4. Hello forum! I'm trying to learn how to time up my functions by using lazycron but I can't get it fired up. Here's my code in site/init.php: function setEventToRepeat(HookEvent $e) { $wire->log->message("kutsutaan cron"); $events = $wire->pages->find('template=tapahtuma'); die(var_dump($events)); $wire->log->message('Kaikki tapahtumat haettu:' .$events); } $wire->addHook('LazyCron::every30Seconds', null, 'setEventToRepeat'); I get nothing in the logs and can't echo or dump anything Thanks for the help!
  5. I'm trying to get a short routine to run once per day that will look at some pages and send a reminder email when that customer's subscription (yearly) is about to expire. When I run the code in a template then it works without issue, but inside my lazycron service routine, I get an "Error: Uncaught Error: Call to a member function get() on null" as if the database cannot be found. My autoload module is just the sample HelloWorld module included with ProcessWire, editted to perform this task. The whole of it is included below (I've stripped out the code that generates the email because it never gets past $pages->find): <?php namespace ProcessWire; /** * ProcessWire 'LazyCronLoad' module * */ class LazyCronLoad extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'LazyCronLoad', 'version' => 1, 'summary' => 'Just loads a lazy cron callback.', 'singular' => true, 'autoload' => true, ); } public function init() { // initialize the hook in the AutoLoad module $this->addHook('LazyCron::everyDay', $this, 'myHook'); } public function myHook(HookEvent $e) { // called once per day wire('log')->save('user_activities',' lazy cron service routine'); $transport_pages = $pages->find("template=aggregate-entry, aggregate_type.title='Transport'"); foreach ($transport_pages as $page) { if (($page->purchase_date + 30325800 < time()) && ($page->purchase_date + 30412600 > time())) { // between 351 and 352 days wire('log')->save('user_activities', $page->id . ' email reminder sent'); // send email } } } } The first wire('log') shows up but the second one doesn't (the purchase_date condition is met (as demonstrated by running the code in a template close in time to when the lazycron routine executes)). The error log gives the Uncaught Error shown above. I think this is a beginner's mistake with something obvious being missed and would be grateful for any assistance in fixing it.
  6. Hey guys, i have some sort of events/campaigns which have a lifespan. To deactivate them i made a checkbox-field called closed and i have to deactivate them manually. I would like to put two fields in the template, startdate and enddate, which activate/deactivate that checkbox field automatically. Dou you have any idea how to bring that on the run?
  7. 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"); } }
  8. Hi, I'm trying to add a hook to lazycron in my module that finds all pages with a checkbox and then sets less the seconds passed to another field, but as yet have seen anything happen. public function init() { $this->checkboxName = "pdp_pub_later_check"; $this->fieldName = "pdp_pub_later"; $this->addHook("LazyCron::everyMinute", $this, 'publishDefferedPages'); } public function ___publishDefferedPages(HookEvent $e){ // seconds since last lazycron $seconds = $e->arguments[0]; // find all pages with deffered field $defferedPages = $this->pages->find("{$this->checkboxName}=true"); // for each page decrease time for deffered field foreach ($defferedPages as $page) { // get current page time $timeTillPublish = $page->get($this->fieldName); // set time to time minus time past $timeLeft = $timeTillPublish - $seconds; // if time passed 0 or less then publish page $page->of(false); if($timeLeft <= 0){ // remove flags and save $this->publish(); $page->set($this->fieldName, 0); }else{ $page->set($this->fieldName, $timeLeft); } $page->Save(); $page->of(true); } }
  9. Hi guys.. Long time no see... Well, Im back to some web programming again, I have been on tour with a Odense symphony orchestra.. Ok, I havent played with cron or lazycron before, so I was wondering, can it be used to auto refresh a website? I startet a digital signage project, where Im planning to use processwire as the core, and then I need it to refresh or update the player browser every day at midnight, and maybe doing the day, when some of the items are done.. Hope you can give me an answer... // Biorn
×
×
  • Create New...