In components you don't have an exclusion segment:
My subject is to create the opposite of a customer segment.
If I have a customer segment DEVELOPER then I would like to create EXCEPT_DEVELOPER ("Everyone can see this component except DEVELOPER").
We want to override/enhance the core method of Intershop which retrieve the assignement.
The goal to check if the user is in the EXCEPT customer segment dynamically.
...
...
forEach(CustomerSegment csItem : customerSegmentList) {
if(csItem.contains("EXCEPT")){ //EXCEPT~DEVELOPER
String customerSegmentToExcept = csItem.split("~")[1]; //DEVELOPER
if(currentUser.isIn(customerSegmentToExcept)) //current user is in customer segment DEVELOPER
return "Don't display component";
}
}
...
...
return "Display component";
What do you think ? Do you have some advice or another method to achieve this please ? Thank you !
The way to override or enhance the pagelet assignment lookup is to provide a custom PageletVisibilityFilter. In 2016 I gave a speech on that topic at the Intershop Developer Conference.
In general, they are wired in a position/priority based list of out-of-the-box filters and they are executed from highest to lowest priority when a content-entry-point (e.g slot, placeholder, page, include) is rendered.
You need to implement that interface:
And register that implementation with the component framework. A quick look into
app_sf_responsive
revealed the place where to instantiate and wire your instance.Be prepared to override the original out-of-the-box filter for customer segments to express that complement logic your're trying to achieve.