- Issue created by @jrb
- Assigned to jrb
- π§π·Brazil renatog Campinas
Hello @jrb, I hope you're doing well
It would be nice if users could schedule the publishing (and unpublishing) of modals. That way, a modal could be set to appear on a given date/time and then go away automatically.
For example, a modal warning of system maintenance could be set to appear the day before the maintenance started and to go away after it occured.Amazing feature!
It can also be used to publish Modals on planned campaigns for exampleI looked into creating a plugin to work with the Scheduler
When reading, it was the first solution on my mind as well lol
I don't think that is possible. I don't think that module will work with config entities. At least, I couldn't figure it out
Right
I'm using Scheduler on my site but it's a Content Entities and not for Config Entities. Nice catchThis could be done by adding "Publish on" and "Unpublish on" fields to the Modal entity and adding a hook_cron() implementation to publish/unpublish based on the current time and those dates.
Agreed!
It's a good alternative and makes sense for meI've got working code that I will add here shortly.
Deal!
I'll stay tunned and available to test and commit itThank you so much for the great suggestion and if you like Modal I'd ask to consider giving a star to encourage the project
- Status changed to Needs review
6 months ago 9:23pm 25 June 2024 - πΊπΈUnited States jrb Raleigh-Durham Area, NC, USA
I've pushed changes to the issue fork. Attached is a patch. This isn't live yet for us, but does work in local testing.
I added some basic documentation to the README:
Modal pages can be scheduled to be published or unpublished at specified times.When you have set up Drupal's standard crontab job, the Modal page scheduling will be processed during each cron run. However, if you would like finer granularity for scheduling but don't want to run Drupal's cron more often, you may use the Modal Page cron handler provided. This is an independent cron job which only runs the scheduler process and does not execute any cron tasks defined by Drupal core or any other modules.
Modal page's cron is at
/modal-page/cron/{cron-key}
. A sample crontab entry to run the scheduler every minute might look like:* * * * * wget -q -O /dev/null "https://example.com/modal-page/cron/{cron-key}"
or
* * * * * curl -s -o /dev/null "https://example.com/modal-page/cron/{cron-key}"
The scheduler may also be run with a Drush command:
drush modal_page:cron
- π§π·Brazil renatog Campinas
About functionality is working fine
phpcs pointed few errors, but it's minor
FILE:/modal_page/README.md ---------------------------------------------------------------------- FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES ---------------------------------------------------------------------- 112 | WARNING | Line exceeds 80 characters; contains 426 characters 114 | WARNING | Line exceeds 80 characters; contains 128 characters ---------------------------------------------------------------------- FILE:/modal_page/src/Service/ModalPageScheduler.php ------------------------------------------------------------------------------ FOUND 4 ERRORS AFFECTING 2 LINES ------------------------------------------------------------------------------ 48 | ERROR | [x] Expected 1 space between double arrow and "$modal"; 2 found 48 | ERROR | [x] Expected 1 space after "=>"; 2 found 61 | ERROR | [x] Expected 1 space between double arrow and "$modal"; 2 found 61 | ERROR | [x] Expected 1 space after "=>"; 2 found ------------------------------------------------------------------------------ PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY ------------------------------------------------------------------------------ FILE:/modal_page/src/Drush/Commands/ModalPageCommands.php --------------------------------------------------------------------------------------------------------- FOUND 2 ERRORS AFFECTING 2 LINES --------------------------------------------------------------------------------------------------------- 36 | ERROR | [ ] Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead 41 | ERROR | [x] Missing function doc comment --------------------------------------------------------------------------------------------------------- PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY --------------------------------------------------------------------------------------------------------- FILE:/modal_page/src/Service/ModalPageScheduler.php -------------------------------------------------------------------------- FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE -------------------------------------------------------------------------- 73 | WARNING | There must be no blank line following an inline comment --------------------------------------------------------------------------
- 9c29b7d5 committed on 5.0.x
Issue #3456333 by jrb, renatog: Support scheduled publish and unpublish
- 9c29b7d5 committed on 5.0.x
- π§π·Brazil renatog Campinas
fixed items listed above and since it's working fine, moved to the dev branch
- Issue was unassigned.
- Status changed to Fixed
6 months ago 3:23am 28 June 2024 - π§π·Brazil renatog Campinas
fixed items listed above and since it's working fine, moved to the dev branch
Thank you so much @jrb
- 1a5a98cc committed on 5.0.x
Issue #3456333 by jrb, renatog: Support scheduled publish and unpublish
- 1a5a98cc committed on 5.0.x
- d3614857 committed on 5.0.x
Issue #3456333 by jrb, renatog: Support scheduled publish and unpublish
- d3614857 committed on 5.0.x
Automatically closed - issue fixed for 2 weeks with no activity.