Only the stack owner, the administrator, or the developer can define the Publish Rules. We have discussed briefly what Publish Rules are, with examples, above. Publish Rules are made up of two parts: Parameters and Conditions.
For every publish rule, you need to define the following parameters:
- Environment: The environment for which the publish rule will be applicable
- Content type: The content type to which the publish rule will be applied
- Action: Whether the publishing rule is for publish or unpublish (or both) action
- Language: The language for which the rule is applicable
Once you have defined the parameters, you need to define a condition.
Note: You can use either one or both of the following conditions for your publishing rule.
- Approver: Use this condition if you want to add an approver to all the entries that are being published or unpublished. Add the user(s)/role(s) who should be authorized to approve the publishing or unpublishing of an entry. For example, if you assign “John Smith” as the approver, every entry that is sent for publishing or unpublishing (and meets the required parameters), will go to John Smith for approval. The entry cannot be published or unpublished unless John approves it. And, if you assign a role, let's say “Content Approver”, as the approver, every entry that is sent for publishing or unpublishing (and meets the required parameters will go to every user who has been assigned this role for approval. The entry cannot be published or unpublished unless any one of the users who is assigned the “Content Approver” role approves it.
- Stage: Use this condition if you want to allow publishing or unpublishing of an entry only if it has reached a certain workflow stage. When this is defined, an entry cannot be published or unpublished unless this defined stage has been reached while creating content. For example, if you have selected Complete here, an entry (that matches the parameters defined above) cannot be published unless it reaches the Complete stage.
A few things to remember:
- Setting up publish rules is optional.
- You need to choose at least one condition (Approver(s) or Stage) for a publishing rule. You can choose both, if required, but at least one is mandatory.
- A publishing rule with Approver(s) as the condition can work independently of workflows. This means that you can add one or more publish rules (with Approver(s) under conditions) even if you have not added any workflows for your stack. However, in order to use the Stage condition for your publishing rule, you will need at least one workflow.
Once a rule is in place, whenever a content manager attempts to publish or unpublish an entry on the specified environment, Contentstack will either send the entry for approval (if approvers are added as a condition), or check if the entry has reached the specified stage (if stage is added as a condition). It will then return the response accordingly.