Assumptions:
You know how to create a fragment.
You know how to create content blocks.
Synopsis:
You want to use a fragment, in a template or a delivery. The fragment can change it's content dynamically based on some logic.
As an example we want to create a footer, that can change content based on a customers preferred language.
Steps:
1. Create the fragments you need in Resources-> Content templates & fragments for example you want to create a fragment in German and in English we can call it:
"footerDE" and "footerEN" and save them
2. Create a Content Block in Resources -> Content Blocks
Put in this code
<% if(context.profile.preferredLanguage=='de_de')
{%> <%@include contentModelFragment='footerDE' %><%}
else
{%> <%@include contentModelFragment='footerEN' %><%}
%>
Save it with a telling name
3. Create a Delivery and use the content block you created above. You will have code in the source that looks like this:
<span class="nl-dce-fragment nl-dce-done" id="span154383380419735" data-nl-name="callFooterFragment" data-nl-label="footer multilingual (callFooterFragment)" contenteditable="false">Footer_Multilanguage</span>
Hi, I'm trying this but I have this error:
SCR-160032 Javascript: failure while compiling script 'TemplateCheck'.
|
JST-310000 Error while compiling script 'TemplateCheck' line 316: missing } after function body (line='' token='').
This is my content block
<% if(context.profile.location.countryCode == 'US') {%> <%@ include contentModelFragment = 'nm_usa_2022' %> <%} %>
Views
Replies
Total Likes