Knowledge Base

T4 Tags outside the tag builder

Last Modified:
10 May 2019
User Level:
Power User

Description

These are tags that can be used that are not available from the Content Type and Page Layout tag builder.

Language variable tag (type="lang-var")

The Language variable tag allows you to provide text for different languages within Page Layouts and Content Layouts.

Example

Use of this code results in the following output on the published site:

  • On English pages output: "English String"
  • On German pages output: "German String"
  • On French pages output: "French String"
  • On other pages so default language output is used: "English String"

<t4 type="lang-var" default-language="en" en="English String" de="German String" fr="French String" />

Example with other t4 tags

It is possible to use other T4 tags within the Language variable tag. To do this the "process-format" attribute must be set to true and the quote symbols in the nested t4 tag must be replaced with quotes ".

<t4 type="lang-var" default-language="en" process-format="true" format-modifiers="" en=" " es=" " ar=" " />

Secondary publish (type="warning")

The tag is useful on multiple language sites and publishes a language disclaimer when Secondary Publish is in use on a Channel. In this case, a disclaimer will be generated for content that has not been translated into a secondary language.

The text for the disclaimer can be added at both the Channel and Language level. If a disclaimer for a language appears in both Channel and Language level, the Channel disclaimer is used.

The examples are based on a Channel with the following languages: 

  • English is set to Publish, is the Default language and Secondary Publish is active
  • German is set to Publish

If content exists in English and it has not been translated in German then a T4 Tag can be used to publish the disclaimer on the German page alongside the English content. The T4 Tag can either be added to the Page Layout or to the Content Layouts. The difference between the two is the logic used to see if any output is necessary:

  • T4 Tag in Page Layout: will print the disclaimer if any content in the Section is taken from the Secondary publish language. 
  • T4 Tag in Content Layout: will print, on a per content basis, if that Content Item is taken from the Secondary publish language (which may result in multiple disclaimers on the page, if there are multiple Content Items that are not translated).

Example tag added to a Page Layout

<t4 type="warning" output="lang_disclosure_style" />

This will be published on the German (Not translated) page, either before all content or after all content:

<p>Keine deutschsprachigen Inhalte hier</p>

Example tag added to a Content Layout

<t4 type="warning" output="lang_disclosure_template" />

This will be published on the German (Not translated) page for each Content Item using a Content Type where the tag is added to the Content Layout:

<p>Keine deutschsprachigen Inhalte hier</p>

Ancestor or Parent name (type="parentnames")

This tag can be added to a Page Layout or Content Layout and outputs the name(s) of the parent section(s). It can generate the name of one section (for example the parent section), or a breadcrumb-style format which generates the name of multiple ancestors (for example the grandparent and parent sections).

This is an extra Add On to TERMINALFOUR and hence may not be enabled in your TERMINALFOUR. Please contact Client Support to install this for you if you do not have access to your database.

Enable the Ancestor Broker

To enable the Ancestor Broker, the below sql statement will have to be entered in the database:

insert into sm_brokers values ('com.terminalfour.publish.brokers.AncestorBroker', 1);

Configure the Ancestor Broker

The following configuration options are required. For each of these, a default value is specified. If the field is not specified within the tag, or if the value entered does not match the expected value, then the default is used.

ItemDescriptionDefault Value
separator Characters used to separate the names of the sections. Similar to the Selective output, this is parsed for t4 tags and allows " to be used for quote symbols.  
start-level

Numerical value for the level at which to start generating ancestors. If this is set to 0, it will start at the current section. If set to 1, it will start at the parent section.

The default value is 0
number-of-levels Maximum number of levels to recurse. If this is set to 2 then it will output 2 levels. If "start-level" is 0, then 2 levels will be the current level and the parent. If "start-level" is 1, then 2 levels will be the parent and the grandparent. The default value is endless, which will output as far as the channel root
first-child A value of "true" or "false". If this is set to true then it will stop recursing up the tree where a section is not the first child in the hierarchy. If false, then it will continue to recurse the tree, regardless. The default value is "true"
first-content A value of "true" or "false". If this is set to true then it will only parse the tag if it is the first Content Item in the section for that channel. If false, then it will always parse the tag. If the tag is within the page layout then first-content will not be checked. The default value is "false"
empty-section

A value of "true" or "false". If this is set to true then it will stop the search once it encounters an ancestor section that contains content and it will not output the name of the section if it contains content, i.e. it will only output the names of empty sections (and maybe the current section).

The default value is "false"

Examples

The following T4 tags can be added to a Page Layout or Content Layout:

Output the name of the parent section

<t4 type="parentnames" separator="" start-level="1" number-of-levels="1" first-child="false" first-content="false" empty-section="false" />

or it could be formatted without the unnecessary attributes:

<t4 type="parentnames" separator="" start-level="1" number-of-levels="1" />

Output the name of the current section

<t4 type="parentnames" separator="" start-level="0" number-of-levels="1" first-child="false" first-content="false" empty-section="false" />

or it could be formatted without the unnecessary attributes:

<t4 type="parentnames" separator="" number-of-levels="1" />

Output the name of the parent section and current section, for the first Content Item on a page

Add the following T4 tag to content layout for one or more content types:

<t4 type="parentnames" separator=" > " start-level="0" number-of-levels="2" first-child="false" first-content="true" empty-section="false" />

or it could be formatted without the unnecessary attributes:

<t4 type="parentnames" separator=" : " number-of-levels="2" first-content="true" />

This will generate an output similar to Name of Parent Section : Name of Current Section if the Content Item is the first Content Item on the page.

Output a separator text which includes a quote symbol

Similar to the selective output tag, if you need to output a quote symbol as part of the separator text, then it needs to be changed to &quot;. For example:

<t4 type="parentnames" separator=" <span class=&quot;separator&quot;>:</span> " start-level="0" number-of-levels="2" />

This will generate an output similar to

Name of Parent Section <span class="separator">:</span> Name of Current Section

Output a different separator text in different languages

For multiple language sites, the language variable tag is used to specify different text in different languages. This can be used within the separator tag as follows:

<t4 type="parentnames" separator=" <t4 type="lang-var" default-language="en" en=" is the parent of " ga=" mar tuismitheoir do " /> " start-level="0" number-of-levels="2" />

In English this will generate an output similar to:

Name of Parent Section is the parent of Name of Current Section

In Gaeilge this will generate an output similar to:

Name of Parent Section mar tuismitheoir do Name of Current Section

Server-side Link (type="sslink")

The Server-side link tag is used for generation of section and content links and should not be changed manually.