Code for Liferay's /dev/24 talk:
How to create your own segments criteria
- Short introduction to Segmentation and Personalization
- Personalization in Action!
- Creating complex segments:
- User & Organization criteria: fields and custom fields
- Session criteria: session properties, request attributes, cookies, etc
- Segments criteria: segments as criterion. Introduced in 7.3.
- Hands-on Creating a Segment Criteria Contributor
This repo will guide you step-by-step on how to extend the Liferay Segments Criteria capabilities by creating your own Segment Criteria Contributor. As an example we'll create a contributor that segments users based on the Knowledge Base articles they have authored.
- Make your related entity (KBArticle) searchable through OData queries:
- EntityModel: represents your associated entity with its fields of interest.
- ODataRetriever: obtains the KBArticles that match a given OData query.
- Customize fields of type ID to use an entity selector:
- ItemSelector: Provides a KBArticles selector.
- SegmentsFieldCustomizer: Connects the ID field with the ItemSelector and provides a meaningful field value name.
- Create the SegmentsCriteriaContributor: It contributes a query to filters users based on the articles they authored.
Follow the commits for a step by step explanation.
Clone the repo and run the following:
LIFERAY_HOME=<your liferay home folder> ./gradlew deploy
In my case:
LIFERAY_HOME=~/projects/liferay/portal/bundles ./gradlew deploy ./gradlew deploy
Thanks to @4lejandrito, and the @liferay-tango team for helping with this talk.