With the site I'm working on, the editor wants to be able to move content through states (draft, needs review, ready to publish, publish). But for the publish state, set up a schedule to publish the content at midnight the next day.
I have my various states configured in workflow. That's working fine.. and workflow schedule is able to switch between these workflow states once the cron runs. However - my problem is with the publish state.
I have a rule that actually publishes the node when the user assigns the workflow state of "publish". But, the rule is also publishing the node even when the workflow state is scheduled for some future time. As soon as the workflow is saved the rule triggers. I'm lost as to how to configure the rule to see the schedule.. ?
Maybe I need two rules: One that publishes as it is now, but on a condition that the workflow isn't scheduled (how to get that condition)? And another one that publishes the node on the schedule.
I'm using Workflow Field.
Can anyone point me in the right direction?
Comments
Comment #1
wheelercreek CreditAttribution: wheelercreek commentedThis is my current rule:
Comment #2
wheelercreek CreditAttribution: wheelercreek commentedOkay after spending a couple days watching rules tutorials and trying different things with it, I'm scrapping that whole idea. I just can't seem to get what I need out of rules. So I decided, this shouldn't be that hard, I'll just write a custom module to publish the nodes on cron job if that workflow state is scheduled. I'm really close but now hitting a new snag. Here's my code:
When the cron runs, I'm able to verify that the nodes actually do get published - with those Watchdog messages. However, Workflow is for some reason resetting them back to be unpublished?? The workflow cron function runs after mine here, and takes care of the scheduled workflow state change.. but why are the nodes reset back to unpublished?
I don't get why this is so difficult.
Comment #3
wheelercreek CreditAttribution: wheelercreek commentedComment #4
wheelercreek CreditAttribution: wheelercreek commentedGot this worked out - in case anyone else runs into this issue. My code above is pretty close, I just added more to actually perform the scheduled Workflow field state transitions myself (updating the field tables), and then clear out records from the workflow_scheduled_transition table so that when the actual WF cron function runs it doesn't find them.
I still don't know why the nodes were getting set back to unpublished, but clearing out the scheduled_transitions table seems to fix it.