A condition is rule that is made up of one or more predicates. A predicate is something that can only ever be true or false. A condition allows you to express that predicate a and predicate b must be both true for the condition to be true.
Here's a simple example. If you are responsible for marketing, you may want to control what banners are shown on your home page. You may want to show a specific banner slide advertising a special offer only to people that have followed you on Twitter and have ordered before.
Therefore, the predicates are:
- User followed us on Twitter
- User has ordered from us before
The condition is:
- The user has followed us on Twitter and has ordered from us before
The condition could also be:
- The user has followed us on Twitter or has ordered from us before
In this tutorial, we are going to walk you through how you could show a discount banner if the user was a high priority user.
In this case, I would consider a high priority user being somebody that is a 'Premium' member and has £50 in their shopping basket.
In Umbraco, navigate to a content page that has uCondition set up.
You will see a blank condition. If you click the top grey area, you can add a description for the condition. In this case, the description of this condition is "If the user is a high priority user".
Hover over the white area and you will see a blue plus button:
Click this button and a 'Add Condition' side bar will appear on the right hand side of your screen. Here you can select from a range of predicate types.
To achieve my condition, I will click the "Is member in group" predicate and "Has amount in basket" predicate. Once you have selected them, it should look like this:
Now click "Add Condition". These predicates require you to configure them, so the configuration will automatically open for each predicate. First it will ask to configure the 'Has amount in basket'.
Now we click "Accept Changes" and the configuration for "Is member in group?" will appear.
I configured the "Is member in group?" predicate to check if the member is in the premium member group and I selected "All".
Click "Accept Changes".
The condition is now set up to check if the user is a premium a user!
In your conditions you will want to express whether something should be true or any could be true.
By default, when adding a predicate, the predicate will be added with a AND. You can change this by clicking the symbol.
||This means AND
||This means OR
Predicate groups allow you to create complex conditions. When you create a predicate group, the predicate group must evaluate to true for the predicate group result to be true.
For example, if you wanted to show a banner if the user was a premium member and the user has spent £50 in store or has £20 in the basket. The condition for this would be:
User is premium member AND (user spent £50 in store OR has £20 in basket).
This is because the user MUST be a premium member, but user spent £50 in store OR has £20 in basket, only one of the latter has to be true.
Here is how that would look in uCondition:
You can nest predicate groups. The same rules apply as mentioned in the 'Predicate Groups' section of this page.
To edit a predicate, simply click on the predicate. The configuration side bar will appear. You can then Accept or Cancel the changes.
To delete, simply hover over the predicate and a trash icon will appear. Click the trash can.
To delete a condition, hover over the condition and a trash icon will appear. Click the trash icon. Be aware, this will delete all predicates within the condition.