Complex content segmentation needs in Liferay DXP 7.2 can be solved by using InfoListProvider.
Basically, you just have to create an implementation of InfoListProvider, declare the type of the contents in your list, and return the desired list of contents using your own strategy of query.
Here is a real world scenario of content segmentation:
-
General objective: Find the banner to be displayed in the principal portal page
-
Rules:
-
- Find the most recent JournalArticle. At least one of its tags must to match with at least one of the tags of the logged user.
-
- If there is no JournalArticle in the filter above, so find the most recent JournalArticle set by public for everyone.
-
- Important: In the two filters above, it is only be accepted JournalArticles that have been published in the last 48 hours.
-
- If any of the conditions above were satisfied, so any JournalArticle will be displayed.
-
Here is the code used to cover those rules.
I’ve been used elasticSearch queries instead of conventional SQL in order to gain better performance.
Source: https://github.com/marceltanuri/content-segmentation-with-info-list-provider
References: