Objective
The goal of this article is to show you the numerous possibilities how to use TAL for the creation of eMailing/LeadPage and article templates. The following examples are covered:
- Individualized page title
- Select language container based on profile language
- Flexible navigation from the link list of the content container
- Use image picker for header image in the Visual Editor
- Editorial with personal salutation and table of contents
- Outputting single and multi-column slots with TAL
- Flexible navigation with the help of a SmartLink
- Article template with TAL
Individualized page title
In this example the following is demonstrated:
- Depending on whether the current e-mail is generated with a profile, either the subject is set as the page title or a fallback text.
<head> <title
tal:condition="not: THIS/getCurrentUser/isDummy">${THIS/getSubjectForCurrentUser}</title> <title tal:
condition="THIS/getCurrentUser/isDummy">This is a general title</title> </head>
<That
's the personalized subject for John Doe.
The following TAL functions are used:
Select language container based on profile language
In this example the following is demonstrated:
- The language of the current profile is read out. If none is set, German (id = 1) is the fallback.
- All containers in the specified folder ("langFolder") are scanned. The container whose name corresponds to the profile language is set as the language container (langContainer).
- If no matching container is found because there is no matching container for the current language, the English language container remains as a fallback.
- The attribute "READMORE" of the language container is output.
<div tal:define="lang THIS/getCurrentUser/getValuesRaw/LANGUAGE|string:1; langFolder string:1681176;global langContainer THIS/getContainer/23471899" tal:omit-tag="true" tal:repeat="object THIS/getCategoryContent/byDescription/${langFolder}" style="display:none"> <div
tal:condition="equals:string:${lang}/${object/getDescription}" tal:omit-tag="true"> <div
tal:define="global langContainer THIS/getContainer/${object/getId}" tal:omit-tag="true"> </div> </div> </div>
<span>${langContainer/getAttributeByName/READMORE}</span>
<span>Read on</span>
The following TAL functions are used:
- eMailing/LeadPage:getCurrentUser
- Profile:getValues
- eMailing/LeadPage:getContainer
- eMailing/LeadPage:getCategoryContent
- Object:getDescription
- Object:getId
- Container:getAttributeByName
Flexible navigation from the link list of the content container
In this example the following is demonstrated:
- To generate a link table, a link list is evaluated from the content container.
- If the link list is empty, the table is not displayed.
- Iterates over every link object in the link list, taking only the first 4 into account.
- If tracking is accepted for the current profile, tracking links are generated. Otherwise the links are not trackable.
The following TAL functions are used:
- eMailing/LeadPage:getCurrentUser
- Profile:isTrackable
- eMailing/LeadPage:getContentContainer
- Container:getAttributeByName
- Link list:getValuesRaw
- Link:getLink
- Link:getTrackLink
- Link:getText
- Integer:lessthan
Use image picker for header image in the Visual Editor
In this example the following is demonstrated:
- If the current e-mail or LeadPage is displayed in the Visual Editor, an image picker is used.
- Otherwise an image is displayed whose URL is stored in the INPUTFIELD_9.
- The image is automatically scaled to a width of 800 pixels.
- The image picker reads all images from the corresponding directory and offers them as selection.
- The ID of the image directory is in INPUTFIELD_10.
- Finally, the JavaScript required to display the image picker is only loaded when displayed in the Visual Editor.
<img alt="Header" id="INPUTFIELD_9_img" src="https://scnem.com/art_resource.php?sid=dz406.3k1mpn,width=800" />
The following TAL functions are used:
- eMailing/LeadPage:isAppendMode
- eMailing/LeadPage:getInputFields
- eMailing/LeadPage:getCategoryContent
- Object:getDescription
- Object:getUrl
Editorial with personal salutation and table of contents
In this example the following is demonstrated:
- If the e-mail is generated with a profile, a personal salutation is displayed. Otherwise, a fallback text is displayed.
- The editorial is inserted as a replacement variable so that it can be edited in the Visual Editor.
- If there are articles in the current e-mail, a table of contents is displayed.
- For this purpose, all filled slots are iterated through. An unsorted list is generated for each slot.
- For each article in the respective slot, a link is inserted with a jump marker to the article and the article title as link text.
- If there is more than one article in a slot, they are numbered consecutively.
The following TAL functions are used:
- eMailing/LeadPage:getCurrentUser
- eMailing/LeadPage:hasArticleInAnySlot
- eMailing/LeadPage:getFilledSlots
- Articles:getAnchorHRef
- Article:getAttributeByName
- Article:getSortPosPlusOne
- Slot:getArticles
- Slot:hasMoreThanOneArticle
- Slot:hasOneArticle
- Slot:countArticles
- Profile:isDummy
Outputting single and multi-column slots with TAL
In this example the following is demonstrated:
- If the eMailing or LeadPage is output in the Visual Editor, the slots are created in a table using replacement variables.
- A heading is inserted for each slot containing at least one article. This is done in the Visual Editor using replacement variables, in the output of the eMailing or LeadPage using TAL.
- If the eMailing or LeadPage is not called in the Visual Editor and a slot contains at least one article, a table is created for this slot.
- Depending on the slot, the articles are displayed in a table with one, two or three columns.
The following TAL functions are used:
- eMailing/LeadPage:isAppendMode
- eMailing/LeadPage:getSlots
- eMailing/LeadPage:getInputFields
- Slot:hasArticles
- Slot:getArticles
- Slot:getArticlesInTwoColumns
- Slot:getArticlesInColumns
- Article:renderWithTemplate
Flexible navigation with the help of a SmartLink
In this example the following is demonstrated:
- Depending on whether one or more links are contained in SmartLink, a table of links is created or a single link is output.
- If the current profile has agreed to tracking, tracking links are generated.
The following TAL functions are used:
- Integer:greaterthan
- String:equals
- eMailing/LeadPage:getSmartlink
- eMailing/LeadPage:getCurrentUser
- Smartlink:getLinklist/getCount
- Smartlink:getLinklist/getLinks
- Link:getTrackLink
- Link:getText
- Link:getLink
- Profile:isTrackable
Consider URL parameter for link to online version
In this example the following is demonstrated:
- The link to the online version of the emailing is only displayed if the URL parameter ("online") is set.
- The corresponding parameter is appended to the link to the online version.
<p tal:condition="not:equals:string:${REQUEST/online}/true">If this newsletter is not displayed correctly please click <a href="{$ONLINEMAIL_URL},online=true">here</a></p>
<p>If this newsletter is not displayed correctly please click <a href="https://scnem.com/a.php?sid=dz4jt.25k269g,f=1,u=5e1a1a9464d35aefb8ac5f1502118a70,n=dz4jt.25k269g,online=true">here</a></p>
The following TAL functions are used:
Article template with TAL
In this example the following is demonstrated:
- A language container is loaded via the eMailing/LeadPage object belonging to the article. The ID of the language container is in INPUTFIELD_0 of the eMailing- or LeadPage.
- A jump marker is placed on the article.
- Depending on whether the current article has an even or odd position in the current slot, a column is inserted to the left or right of the article text.
- The position of the article within the slot is built into the article heading.
- A METAL macro is used for the article image. This means that the source code for the article image only has to be written/changed once instead of four times.
- The URL of the image is read from an article attribute.
- If a landing page link is provided, the image is linked and a call-to-action link is displayed.
- An attribute from the article is read as the label of the call-to-action link. If this is empty, the corresponding text from the language container is used as a fallback.
The following TAL functions are used:
- Articles:getAnchor
- Article:getAttributeByName
- Articles:getNewsletter
- Article:getReadLpLinkOrLpUrl
- Article:getSortPosPlusOne
- Article:hasAttributes
- Articles:hasLandingPage
- Articles:isEven
- Article:isOdd
- Container:getAttributeByName
- eMailing/LeadPage:getContainer
- eMailing/LeadPage:getInputFields
- String:equals