Overview
Transitions are the paths between states.
If you tested the workflow we made in Lesson 2 - States, you will have noticed that every state could transition to every other state. That's the default behavior of states – unless you specify otherwise.
Submit transition
We'll start with the transition from the Editing state to the Review state.
When we're in the Editing state, we only want a single choice – go to the Review state. For that, we need a submit
transition.
Edit your workflow, as shown in the previous lesson, and add submit=Review
parameter to the Editing state:
{workflow:name=Simple Content Production Process} {state:Editing|taskable=true|submit=Review} {state} {state:Review|taskable=true} {state} {state:Published|final=true|taskable=true} {state} {workflow}
Notice that we put a | (a pipe character – that vertical, sometimes split, line near the Enter key on your keyboard) between the taskable=true
parameter and the submit=Review
parameter.
What are parameters?
Most Macros can have settings, called parameters.
Usually, parameters look like name=value
– for example, taskable=true
. However, some macros support a special Unnamed first parameter that only needs the value
part. You can see both types in the markup above.
Between the macro name, and the first parameter – regardless of whether it's a named or unnamed parameter – there must always be a colon ":".
And, between each parameter, there must be a pipe "|".
Review transitions
In our Review state, we want two possible transitions:
- If the content is
approved
, we want to go to the Publish state - If the content is
rejected
, we want to go back to the Editing state
Let's make those changes to our workflow:
{workflow:name=Simple Content Production Process} {state:Editing|taskable=true|submit=Review} {state} {state:Review|taskable=true|approved=Published|rejected=Editing} {state} {state:Published|final=true|taskable=true} {state} {workflow}
Published transition
Once content is Published, we generally leave it in that state. However, what happens if someone edits it?
We can use the updated
transition to automatically move to another state – like the Editing state – if someone edits the content. Here's our updated workflow:
{workflow:name=Simple Content Production Process} {state:Editing|taskable=true|submit=Review} {state} {state:Review|taskable=true|approved=Published|rejected=Editing} {state} {state:Published|final=true|taskable=true|updated=Editing} {state} {workflow}
Test it
Now, try testing the transitions in your workflow.
Did you notice that there was only one option in the Editing state – to transition to the Review state, but not the Published state?
And when you transitioned to the Review state, did you get stuck?
It's time for the next lesson: