1

I am working on Drupal 7 on a custom content type that is called Event.

Each created Event is programmed to be displayed for 1 hour before been deleted. I am using rules component scheduler for that and it works well.

Now I need to be able to increase that display duration.

I already created a numeric field called duration that take the value of the duration from the user. That value that I want to add to the initial display duration.

I need to use that duration field in the Scheduled evaluation date. But rules denied using the + with an identifier.

Can anybody help ?

How do I increase the duration of a tasks that has already been scheduled on node creation. How do I do that using a field that take the value to add?

  • 1
    Please include an export of the rule you already have. AND provide more details on how you defined that numeric field (what is, in your opinion, the MEANING of that "integer"). AND explain "when" the user enters that "duration", is it when the node is created, or something like a node update while the "1 hour" timeframe has already started? – Pierre.Vriens Sep 2 '17 at 19:03
  • Thanx for the answer @Pierre.Vriens. The field duration is an integer. The content is deleted "1 hour" after been created. So the user can only increase that duration while it is available. – mosgeorges Sep 2 '17 at 19:19
  • Your question already said that duration was "integer", but you still did not say what its "meaning" really is, I bet it is not a dollar amount, so what is it then? And from your last phrase I "deduct" that the answer to my last question is "via an update of the node". Can you please ALSO include an export of the rule you have so far, for which you wrote "works well". That way I don't have to make a zillion of assumptions to provide an answer, instead just answer with "this is what you need to add/correct", OK? – Pierre.Vriens Sep 2 '17 at 19:28
  • I forgot to say that in fact I created two rules. The first one uses a component on scheduler to delete that content after one hour. The second is the one that is not finished and is supposed increase the time value (This is where I am in trouble).. – mosgeorges Sep 2 '17 at 19:56
  • Here is the first rule : { "rules_event_hidden_behavior" : { "LABEL" : "Event hidden behavior", "PLUGIN" : "reaction rule", "OWNER" : "rules", "REQUIRES" : [ "rules", "rules_scheduler" ], "ON" : { "node_insert" : [] }, "IF" : [ { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "event" : "event" } } } } ], – mosgeorges Sep 2 '17 at 19:56
1

What you'll have to do to get this to work, consists basically of these steps:

  1. Create a new rule using event "After updating a node of content type Event, in which you add a Rules Condition to check that the value of the duration field was changed (I suppose you know how to write such Rules Condition).
  2. The Rules Actions to be performed in this new rule to be created, consist of these 2 Rules Actions (in the order specified):

    • Delete the scheduled Rules Component that got scheduled when the node (Event) was created. That way the node will not get deleted as originally planned. For way more details on that, refer to my answer to "How to delete a scheduled task using Rules Scheduler?". Make sure to understand that it is extremely important, for this to work correctly, that you usve a unique identifier of the scheduled rule ... using the node title for it is asking for trouble (what if 2 nodes have the same title???), which is why I always make the node's nid part of such identifier.
    • Schedule the same Rules Component you already have (to delete the Event later on) AGAIN, using your "duration field".

What this really means is that your implementing logic that reads something like so "Don't delete this node (Event) after one hour yet, instead give me X more time (as indicated in your duration field) from now on (= the moment the updated node (Event) is updated with that duration field update)".

  • THis sounds likes wise answer @Pierre.Vriens. Let me try that and I'll give you feedback. And the "X more time" is a good idea... – mosgeorges Sep 2 '17 at 20:17

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.