Optimizely Spire CMS provides a feature to create variants of CMS pages. Page variants are variations of a website page with rules for displaying it to end users. Optimizely Spire CMS supports page variants for all CMS pages, including the header and footer. The primary purpose of that user is to see different variations of the same page.
Optimizely Spire CMS provides a feature to apply rule types on page variants. Optimizely Configured Commerce supports creating custom rule types and rule type options to further use the Rules Engine. The basic requirement of creating a custom rule type or using OOTB on a rule type is that users can see different CMS pages as per the applied rule type.
This blog provides complete information on creating custom rule-type options. The steps below will help create a custom rule type option in the Optimizely Configured Commerce solution that can be used in the Optimizely Spire CMS.
How to Create a Custom Rule Type Option in Optimizely Spire CMS
- Open Optimizely Configured Commerce solution in Visual Studio.
- Go to the “Extensions” class library.
- Create a new class, “CustomRuleTypeOption,” and inherit it from the “CriteriaTypeBase” base class. Add Dependency Name attribute with a name of “CustomRuleTypeOption“.
- Implement inherited abstract class members.
- Change the DisplayName property value to “Custom Rule Type Option“.
- Override the remaining properties value.
- To show custom rule type option field in CMS, we need to override the “ParameterDescriptions” property and set “Label” and “ValueType” value.
- Override the Validate method and add business logic to validate the input value specified in the CMS. If “true” is returned, the user will see the page variant. If “false” is returned, the user will see the default page.
- Rebuild the solution.
- Login in Admin.
- Go to Administration -> System -> Rule Types listing page.
- Open the “Page” rule type from the listing page.
- Go to “Rule Options” tab and click on “Rule Type Option” button.
- Enter “Description” and select the custom rule type option from the “Criteria Type” dropdown and click on the “Save” button.
- Log in as a content admin and click the “Edit” icon.
- Go to any page and create a variant of the page. For example, go to Header and click on More Options (…).
- Select “Create Variant“.
- Enter a “Variant Name”, select “Copy Content from Default” and click on “Save” button.
- Select the custom rule type option from the rule type dropdown, enter the value, and click the save button.
- As per the rule type, verify the variant page on the site.
References:
- https://support.optimizely.com/hc/en-us/articles/4413199746317-Manage-page-variants
- https://docs.developers.optimizely.com/configured-commerce/docs/create-custom-rule-type-option-for-cms-variants
- https://support.optimizely.com/hc/en-us/articles/4413200007437-Rule-type-options
__PRESENT
__PRESENT
__PRESENT
Source: Read MoreÂ