Attention

TYPO3 v6 has reached its end-of-life April 18th, 2017 and is not maintained by the community anymore. Looking for a stable version? Use the version switch on the top left.

There is no further ELTS support. It is strongly recommended updating your project.

Insert content in a template

We now know how to render content, and how to build a menu; but we still do not have a real website, yet.

We could build a website with COAs, and create the complete HTML skeleton with TypoScript. However, this would be very complex, and prone to errors. If the HTML template file has been built by a template designer and is delivered completely done, it gets even more complicated, especially with slight changes in the layout, afterwards.

Therefore, we have the object TEMPLATE, with which we can parse an HTML template file, and insert the menu, content, and so on, at the right place into it.

page.10 = TEMPLATE
page.10 {
 template = FILE

 # We load the HTML template file.
 template.file = fileadmin/test.tmpl

 # Text areas in the template file:
 # <!-- ###MENU### begin -->
 # Here is an example of content as placeholder, everything which is
 # in between the markers will be replaced by the content of the
 # sub-parts, in this case by the menu.
 # <!-- ###MENU### end -->

 # Subparts are a pair of two markers (like "###MENU###" above).
 subparts {
   MENU < lib.textmenu
   CONTENT < styles.content.get
   COLUMNRIGHT < styles.content.getRight
 }

 # Marks are single markers. That is, there is no start and end marker;
 # instead, the marker is replaced directly. ###LOGO### will
 # be replaced by the logo.
 marks {
   LOGO = IMAGE

   # Use the graphic logo.gif.
   LOGO.file = fileadmin/templates/logo.gif

   # The logo links to the page with ID 1.
   LOGO.stdWrap.typolink.parameter = 1
 }
 workOnSubpart = DOCUMENT
}

With the TEMPLATE object, TYPO3 offers a way to replace markers in an HTML template with content generated by TYPO3.

One marker is called a mark. Two markers with the same name (like <!-- ###MENU### begin --> and <!-- ###MENU### end --> above) are called a subpart. When TYPO3 finds marks or subparts in the HTML template, it will replace them - and in case of subparts everything between them - with what you defined in the TypoScript template for the according mark or subpart. In this example, the subpart MENU will be replaced by the rendering of lib.textmenu.

An alternative to this solution could be the extension automaketemplate, with which it is possible to abandon markers completely. Instead, it uses IDs as references, and thus allows better cooperation with the template designer.

Another alternative would be the extension templavoila. This extension provides a visual user interface. This is not recommended for beginners, though.