- π³π±Netherlands Bigbozz
Can you please give an update of the migration to D8/9/10? I used this module on my old D7 site and it is/was very useful. For my new site I hope that you can make a D10 version of it. That would solve some problems for me. Or is there any alternative that I don't know yet?
- π¬π§United Kingdom fonant
Hi there, development stopped while the Rules module, which this module depends on, was ready for Drupal 8 and later.
Looks like that's nearly the case, I'll have a look at what changes are needed here.
- πΊπΈUnited States safetypin Memphis, Tennessee
So, my issue was that I wanted a node to be created automatically, once per day, and I was able to create a custom module that creates a custom cron task that does this in code. It is two files. If you can figure out how to do what you want to do in code, then you can replace the contents of the
if (REQUEST_TIME >= $next_execution)
block below:once_per_day.info.yml:
name: Once per Day type: module description: A custom module to automate daily node creation. core_version_requirement: ^9.2 || ^10 package: Custom dependencies: - drupal:node
once_per_day.module:
use \Drupal\node\Entity\Node; /** * Implements hook_cron(). * * We implement hook_cron() to do "background" processing. It gets called every * time the Drupal cron runs. We then decide what has to happen in response. * * In this example, we log a message after the time given in the state value * 'cron_example.next_execution'. Then we update that variable to a time in the * future. */ function once_per_day_cron() { // We access our configuration. $cron_config = \Drupal::configFactory()->getEditable('once_per_day.settings'); // 86400 seconds = 1 Day $interval = $cron_config->get('interval'); $interval = !empty($interval) ? $interval : 60; // We usually don't want to act every time cron runs (which could be every // minute) so keep a time for the next run in the site state. $next_execution = \Drupal::state()->get('once_per_day.next_execution'); $next_execution = !empty($next_execution) ? $next_execution : 0; if (REQUEST_TIME >= $next_execution) { $node = Node::create([ 'type' => 'once_per_day', 'title' => date('F j, Y', REQUEST_TIME) // date_iso8601(REQUEST_TIME) ]); $node->save(); \Drupal::logger('once_per_day')->notice('once_per_day ran'); \Drupal::state()->set('once_per_day.next_execution', strtotime('tomorrow +7 hours')); } }