Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Tips: Using content blocks to call HTML fragments

robayzma
Level 4
Level 4

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>

0 Replies