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?

5
  • 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. Commented Aug 10, 2016 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
    Commented Aug 10, 2016 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. Commented Aug 10, 2016 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
    Commented Aug 10, 2016 at 20:06
  • Interesting business opportunity then to get your question resolved ... using custom code I assume ... until the Rules module is production ready? Commented Aug 10, 2016 at 20:12

2 Answers 2

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

1
  • We are gonna give the Scheduler a go and see if we can get it running in D8 thanks for the suggestion.
    – JBo DevMan
    Commented Aug 11, 2016 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.

2
  • 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
    Commented Mar 7, 2020 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
    Commented Mar 8, 2020 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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