Enonic version: 6.11
In site.xml:
<!-- Used for Fragments to work in XP Content Studio preview -->
<mapping controller="/site/pages/default/default.js">
<match>type:'portal:fragment'</match>
</mapping>
In default.js:
const isFragment = content.type === 'portal:fragment';
In default.js view, do not render regions and then:
<!--/* Render Fragments (single view, supported with mappings in site.xml) */-->
<main th:if="${isFragment}" th:remove="tag">
<div data-portal-component="fragment" th:remove="tag"/>
</main>
2 Likes
You can also see how this was done in the “sample blog” app:
1 Like