About page rules
Page rules are actions that can be automatically triggered based on conditions you define as soon as a user enters a page.
For example, let's say your users can register for a specific event with limited availability. A page rule can be defined to hide the registration form when availability reaches zero.
Add a page rule
You can find the Rules link in the top menu of a page in the Pages builder. If you have already added page rules to a page, you’ll see a counter next to the tab showing you the number of rules that are active for this page:
To add your first rule, click on the "Add rule" button:
Define the criteria
Page rules are triggered when specific criteria you define are true.
To set your criteria you need to select a specific field in the "When" section of the new rule.
The fields available to use will depend on the page. Child pages will let you choose fields from the object that page is based on. If the page is protected by a login you will also be able to use fields from the account object and other user roles the login will let access the page.
If no fields are available, the "Rules" link will not be available.
You need to check for at least 1 criteria, but you can add as many as you need in a single rule. If you have multiple fields selected, they must all be true in order for the rule to trigger.
Define the action
Each rule can only perform one action. Select the action that you want your page rule to perform. There are three main actions a page rule can perform: hide views, show a message, or redirect the user to another page:
This action will hide any selected views when your criteria matches:
Show a message
Show a message of your choice. The message will be displayed at the top of the page, above any views.
There are 4 different message styles available; they each have a unique background color for different effects: "Neutral," “Confirmation,” “Warning,” and “Red Alert”.
You can choose whether the message can be dismissed by the user or not. If toggled, an "X" icon on the top-right of the message will be displayed.
Redirect to the parent page
Once set, the user will be redirected back to the page that the child page originates from (otherwise referred to as the parent page).
Knack Tip This action is only available for child pages.
Redirect to an existing page
This action will redirect the user to a specific page.
All start pages are available as well as any other child page that has the same object as a source. If the child page is meant to display a specific record, the same record as the current page will be used.
Redirect to another website URL
With this action you can write your own URL to redirect the user to. Note that there are no ‘back’ crumbtrail links generated, so if you’re linking to an external website the only way back is by using the browser.
Edit a page rule
Existing page rules can be edited at any time. Use the " + “ or “ - " icons to add / remove criteria.
You can drag / drop each individual rule using the left anchor bar to keep your rules organized. You must press the "Save rules" button in order for your changes to take effect permanently:
Delete a page rule
To get rid of a page rule entirely, use the red delete icon to the far right of the rule panel. You must press the "Save rules" button in order to save your changes permanently:
Managing multiple rules
It’s important to note that when you have multiple rules, all matching rules will be triggered at the same time. This is also true for rules that happen to have the same criteria: Knack will not stop triggering rules after the first rule matches.
Take the following scenario for example:
There are two page rules that will trigger when Registrations Available is lower than 1. The first rule will display a message and the second rule will hide a view. In this scenario both rules will trigger, so the user will see a message and the view will be hidden as well.
Tweaking that scenario, the second rule will now redirect the user instead:
Technically both rules are still going to trigger, but since the user is being redirected out of the page they are never going to see the first message.
Page rules examples
The following is a step-by-step guide to creating a registration form with limited availability, and using page rules to hide that form and display a message when availability reaches zero.