Hi all,
Let us say I have created an Experience Fragment.
When clients with different view ports require and request it, how AEM sends the right variant of it?
Based on client view port the experience and Experience Fragment should be different.
So, AEM creates Experience Fragments for each of view port sizes?
How does it know which variant should be served for which client?
Appreciate all your responses,
Thanks,
RK.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
AEM does not automatically create separate Experience Fragments for each viewport. Instead:
In case , you created separate XF variants , then use custom logic in your page templates or components to include the right one based on device detection.
Out of the box, AEM does not automatically deliver different Experience Fragment (XF) variants based on viewport size. An XF is essentially a set of authored components that you can render on a page, but AEM won’t decide which one to serve depending on device type.
If you need different versions for desktop, tablet, and mobile, a common approach is:
<div class="cmp-customxf__desktop" data-sly-resource="${@path=model.desktopXf,
selectors='content', wcmmode='disabled'}"></div>
<div class="cmp-customxf__tablet" data-sly-resource="${@path=model.tabletXf,
selectors='content', wcmmode='disabled'}"></div>
<div class="cmp-customxf__mobile" data-sly-resource="${@path=model.mobileXf,
selectors='content', wcmmode='disabled'}"></div>
/* Mobile: less than 751px */
@media (max-width: 750px) {
.cmp-customxf__desktop,
.cmp-customxf__tablet {
display: none;
}
.cmp-customxf__mobile {
display: block;
}
}
/* Tablet: 751px to 1199px */
@media (min-width: 751px) and (max-width: 1199px) {
.cmp-customxf__desktop,
.cmp-customxf__mobile {
display: none;
}
.cmp-customxf__tablet {
display: block;
}
}
/* Desktop: 1200px and above */
@media (min-width: 1200px) {
.cmp-customxf__tablet,
.cmp-customxf__mobile {
display: none;
}
.cmp-customxf__desktop {
display: block;
}
}
This way, authors can manage content per device type, and the front-end ensures the correct version is displayed.
If you’d like a more dynamic solution, you could also explore personalization with ContextHub/Target, but for a straightforward viewport-based variation, the above approach is usually sufficient.
Thanks @BrianKasingli .
Your explanation has gone one level deeper than what I was expecting.
Thanks,
RK.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies