3

I have a Content type called Event, has a Start Date and End Date.

How do I use the Rules module (version 8.3.0-alpha1) to:

  • Publish the Event on the Start Date and
  • Unpublish it on the End Date?

My priority is to Unpublish the content when the End Date is hit.

Note: If Rules isn't the way to go, what would be a better way to unpublish a piece of content based on a supplied End Date?

  • Which release of the Rules module for D8 are you using? Anything that is not "alfa"? If it is alfa, then there is a simple answer to your "how do I use", i.e.: don't use Rules ... yet. – Pierre.Vriens Aug 10 '16 at 19:42
  • @Pierre.Vriens if rules isn't the way to go what would be a better way to unpublish a piece of content based on a supplied end date. – JBo DevMan Aug 10 '16 at 19:53
  • You didn't answer to my prior comment (= which version of rules are you using?). Though you added an interesting extra comment (which really belongs in your actual question where I tried to add it to, feel free to refine/correct that edit if needed). And to answer your last comment for "a better way": using rules with D7 (instead of D8) ... if you're willing to consider D7 ... sorry, but for D8 I don't know of a better way. – Pierre.Vriens Aug 10 '16 at 20:01
  • @Pierre.Vriens I am using 8.3.0-alpha1. My entire site is already built in Drupal 8 and we can't regress back to 7. – JBo DevMan Aug 10 '16 at 20:06
  • Interesting business opportunity then to get your question resolved ... using custom code I assume ... until the Rules module is production ready? – Pierre.Vriens Aug 10 '16 at 20:12
2

I have this functionality on a D7 site I run, and we use the Scheduler module instead. Looks like there is an alpha release for D8 you could try: https://www.drupal.org/project/scheduler

| improve this answer | |
  • We are gonna give the Scheduler a go and see if we can get it running in D8 thanks for the suggestion. – JBo DevMan Aug 11 '16 at 13:54
-1

You may want to look at https://www.drupal.org/project/business_rules module which seems to be much further along than D8 version of Rules. It, unlike Rules, does have an Unpublish action. The rest, at least in D7, would be to use Views Rules to make a View of all items past their end date and then you could use this View in Rules to loop through all the items and unpublish. Sadly, Views Rules is another module which has not made the D8 cut; but perhaps Business Rules has some sort of Views integration.

| improve this answer | |
  • This answer contains wrong information. Rules has always been able to set the published status - this appears as "node.status (Published)" in the data selector, just like the node title appears as "node.title (Title)". Additionally, the question is "How do I use the Rules module ..." - it is not asking for alternatives or speculative suggestions ("but perhaps" means you haven't even tried this yourself, so you don't even know if it will work). – anonymous Mar 7 at 1:44
  • @anonymous, did you see the post above? "Note: If Rules isn't the way to go, what would be a better way to unpublish a piece of content based on a supplied End Date?" But yes, i see that D8 Rules can set Publish as a "set data value". Cool. Not 100% sure how the loop would be done in Rules now that Views Rules has fallen by the wayside; but perhaps it is there. I have also, recently, discovered what seems like a bug in Business Rules where it unpublishes ALL entities rather than the one triggering the rule. Although this seems like a bug to me; it might actually work for your use case. – liquidcms Mar 8 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.