This page is still a beta!

1.5. <T3DataStructure> extensions

Introduction

TemplaVoila extends the Data Structure XML with a set of tags which defines two things related to TemplaVoila:

  1. Mapping: Definition of mapping rules, descriptions, sample data, and field type preset

  2. Rendering: Definition of TypoScript code, Object Path, processing flags and constants

<T3DataStructure> extensions for “<tx_templavoila>”

“Array” Elements:

Element

Description

Sub-elements

<[application tag]>

In this case the application tag is “<tx_templavoila>”

<title>

<description>

<tags>

<sample_data>

<sample_order>

<eType>

<TypoScriptObjPath>

<TypoScript>

<proc>

<ruleConstants>

<ruleRegEx>

<ruleDefaultElements>

<langOverlayMode>

<ROOT><tx_templavoila>

For <ROOT> elements in the DS

<title>

<description>

<pageModule>

<pageModule>

A bunch of config options which take influence on the rendering in the page module.

<displayHeaderFields>

<titleBarColor>

<sample_data>

Sample data, defined in numeric array. Sample data is selected randomly from these options

<n[0-x]>

<sample_order>

For <section>s: Defines a set of array objects to display as sample data. Each value in this numerical array points to a fieldname in the object <el> array.

<n[0-x]>

<TypoScript_constants>

<[constant_name]>

<proc>

Processing options (during rendering)

<stdWrap>

<int>

<HSC>

“Value” Elements:

Element

Format

Description

<meta><sheetSelector>

string

Defining a file/class with PHP code to evaluation sheet selection in frontend.

Its a getUserObject reference a la “EXT:user_myext/class.user_myext_selectsheet.php:&amp;user_myext_selectsheet” where the class  user_myext_selectsheet contains a function, selectSheet(), which returns the sheet key, eg. “sDEF” for default sheet.

Notice about using sheets in frontend rendering (pi1):

This feature is fairly advanced and still needs some development and documentation. Here are some points to observe:

  1. When sheets are defined the template also needs to be remapped!

  2. If no mapping exists for other keys than “sDEF” then they will default to use the mapping for “sDEF”. Thus it can save you a little on mapping the same over and over again if all sheets use the same template.

  3. When using sheets the local processing XML also needs to be wrapped in eg. “<sheet><sDEF> .... </sheet></sDEF>”

  4. The selection of sheets should be careful to select only based on parameters that are safely cached. This can be done if parameters are known to be cHash protected - or if the page cache is disabled of course.

<title>

string

The title displayed in the mapping view

<description>

string

Mapping instructions / description, shown in mapping view.

<tags>

string

commalist of tag rules. A tag rule is defined as [tagname]:[mapping-mode]:[attribute]

Examples are:

  1. table:outer,div,body:inner,td:inner

  2. *:attr:href

  3. a:attr:*

  4. *:inner,a:attr:href,a:attr:src

<eType>

string

Value pointing to a TCEforms preset. Used for building of Data Structures with templavoila. Automatically set and controlled. This tag only used internally by the mapping tool.

<oldStyleColumnNumber>

integer

By setting this tag to an integer value (usually between 0 and 3), you define to which tt_content column number this field relates. This information is used by the list module, frontend editing and all other places which work with the older column paradigm.

If you want to convert a pre-TemplaVoila site to a TemplaVoila site with the migration wizard you also have to make sure setting oldStyleColumnNumber tags for your content areas.

Note: Each value can only be used once in a data structure and this usage makes only sense in page templates!

Background information:

Before TemplaVoila existed, the content on a page was arranged by assigning each content element to a certain column id. By default four columns were available: “Normal” (id=0), “Left” (id=1), “Right” (id=2) and “Border” (id=3).

Some parts of TYPO3 and some extensions are not aware of the different way TemplaVoila structures content. If you create or move a content element with the List module, the element possibly does not appear at the position where you expect it, because the list module doesn't know which content area reflects the “Normal” column.

Example:

<T3DataStructure>

   <ROOT>

      <el>
         <field_maincontent>
            <tx_templavoila>
               <oldStyleColumnNumber>0</oldStyleColumnNumber>
...

<TypoScriptObjPath>

string

TypoScript object path pointing to a TypoScript Template Content Object which will render the content represented by the element.

Very useful if you want to insert a menu which is defined by eg. “lib.myMenu” in the TypoScript Template of a website.

<TypoScript>

string

TypoScript content.

Constants can be inserted

  1. which are defined locally in <TypoScript_constants>, see below

  2. In the TypoScript template of the website; In the Setup field you can set constants as properties (first level only) in “plugin.tx_templavoila_pi1.TSconst” - those can be inserted by {$TSconst.[constant name]} in the <TypoScript> data!

General example:

<TypoScript>
<![CDATA[
10 = USER
10.userFunc = user_3dsplm_pi2->testtest
10.imageConfig {
  file.import.current = 1
  file.width = 100
}
]]>
</TypoScript>

Access other fields in the same data structure:

<TypoScript>
   10 = TEXT
   10.field = field_myotherfield
</TypoScript>

Display the page title:

<TypoScript>
   10 = TEXT
   10.data = page:title
</TypoScript>

<[constant_name]>

string

A local TypoScript constant which can be inserted by {$[constant_name]} in <TypoScript> (see above)

Instead of setting a plain value you can also reference object path values from the sites TypoScript template by inserting a value like “{$lib.myConstant}”. Notice, the value will come from the Templates Setup field.

Example:

<TypoScript_constants>
  <backGroundColor>red</backGroundColor>
  <fontFile>{$_CONSTANTS.resources.fontFile}</fontFile>
</TypoScript_constants>

Here “_CONSTANTS.resources.fontFile” must be an object path with a value in the TypoScript template of the website!

<int>

boolean, 0/1

Pass through intval() before output

<HSC>

boolean, 0/1

Pass through htmlspecialchars() before output

<stdWrap>

string

StdWrap properties as TypoScript, eg:

<proc>
<stdWrap>
trim = 1
br = 1
</stdWrap>
</proc>

<langOverlayMode>

string, keyword

Setting the mode for content fallback when <meta><langChildren> and other languages are used in flexforms.

Normally inheritance from default language is enabled by default and globally disabled by the TypoScript setting “dontInheritValueFromDefault” if needed.

However through the Data Structure and TO / Local Processing XML you can overrule this per-field by this keyword.

In any case it only affects values from other languages than default and only if <langChildren> is enabled (thus using “vDEF” and sibling fields named “vXXX” for localization).

Keywords:

ifFalse - Content is inherited if it evaluates to false in PHP (meaning that zero and blank string falls back)

ifBlank - Content is inherited if it matched a blank string (trimmed)

never - Content is never inherited from default language!

removeIfBlank - If the value of this field is blank then the whole group of fields (element) is removed! This is a way of removing single elements for localizations in <langChildren>=1 constructions instead of inheriting content from default language.

[default] - If no keyword matches it uses the global mode.

<displayHeaderFields>

string

A list of page-related fields which should be displayed as a header in the edit page view of the page module. By now, only table “page” is allowed / makes sense.

Note: This tag only takes effect when used in the top-level <tx_templavoila> section, ie. one level below the <ROOT> tag.

Example:

<T3DataStructure>

   <ROOT>

      <tx_templavoila>

         <pageModule>
            <displayHeaderFields>
               pages.keywords
               pages.mycustomfield
            </displayHeaderFields>
         </pageModule>
...

<titleBarColor>

color

If you want to help your editors determining which data structure is used for the page they are currently working on, you may specify a color by using this tag. The title bar at the very top of the edit page screen will be displayed in that color.

You may use any value which is allowed in CSS (ie. “red” as well as “#FC2300” etc.)

Note: This tag only takes effect when used in the top-level <tx_templavoila> section, ie. one level below the <ROOT> tag.

Example:

<T3DataStructure>

   <ROOT>

      <tx_templavoila>

         <pageModule>
            <titleBarColor>orange</titleBarColor>
...

Extensions to tags in the Data Structure

  

<[field-name]><type>

string

In the Data Structure only “array” or blank makes sense. However for TemplaVoila there is additional values possible, “attr” and “no_map”. This is a complete TemplaVoila related overview of the <type> / <section> meanings:

  1. <type>array</type> = Renders an array or objects

  2. <type>array</type> + <section>1</section> = Renders a section which must contain other array-types (without <section> set!)

  3. <type>attr</type> = The object is mapped to a HTML tag attribute.

  4. <type>[blank]</type> = The object is mapped to a HTML tag element.

  5. <type>no_map</type> = The object is not mappable (only editing in FlexForms eg.)

Sheets and TemplaVoila

TemplaVoila is compatible with definition of sheets. In that case a sheet <ROOT> element is shown in the mapping structure containing each sheet as <ROOT> elements under it.

Accessing “parent” record from DS TypoScript

Note: This feature is experimental and can be changed in future. All users are warned: use it at your own risk! This notice will be removed when this feature becomes stable.

To access “parent” record from “tt_content” or “pages”  table in the <TypoScript> section of a field, developer can use special registers. These registers defined only when <TypoScript> section is executed. The following example shows how to use these registers:

<TypoScript>10 = TEXT10.data = register:tx_templavoila_pi1.parentRec.uid10.wrap = “uid” field of parent record is |</TypoScript>

Thus any field of parent record is defined as tx_templavoila_pi1.parentRec.XXX register, where XXX is replaced by a field name from the corresponding table.

Notice that these registers are undefined for static data structures because static data structures do not have associated parent record. If reference to  tx_templavoila_pi1.parentRec.XXX appears in the static data structure, result is undefined.