Search by

bmack / modern-template-building

bmack

A homage to the old-style marker-based templating of TYPO3. Includes TEMPLATE and FILE cObjects.

Package info

github.com/bmack/modern-template-building

Type:typo3-cms-extension

pkg:composer/bmack/modern-template-building

Statistics

Installs: 15 044

Dependents: 3

Suggesters: 0

Stars: 15

Open Issues: 0

1.1.4 2025-06-26 19:55 UTC

This package is auto-updated.

Last update: 2026-09-25 04:42:12 UTC


README

Before there was TemplaVoila or later Fluid-based templating, the creator of TYPO3 - Kasper Skaarhoj - created a guide called "Modern Template Building" - where integrators could write HTML templates with placeholders - so-called "Markers" and "Subparts" without having to write everything in TypoScript.

This concept was still available until TYPO3 v10, but is discouraged, as both TemplaVoila, and Fluid offer a lot more ways to create templates in a more flexible way.

For all the nostalgic TYPO3 lovers, I've created this extension, which ships with two "Content Objects" - TEMPLATE and FILE to use them in future TYPO3 versions.

This extension is a perfect example how templates that were created with this approach 20 years ago, still run on TYPO3 v9, v10 or later without having to adopt anything. TYPO3 is loved for its

  • backwards-compatibility,
  • upgrade path and
  • flexibility

and this is what can be achieved with a simple extension.

Installation

Just install this extension (extension key modern_template_building) from the TYPO3 Extension Repository, or via composer req bmack/modern-template-building, and you're good to go.

Once the extension is installed, you can continue to use the cObjects FILE and TEMPLATE in your custom TypoScript code.

Configuration

This is taken from the original TYPO3 documentation and it has been slightly adapted for this extension.

TEMPLATE Content Object

With an object of type TEMPLATE you can define a template (e.g. an HTML file) which should be used as a basis for your whole website. Inside the template file you can define markers, which later will be replaced with dynamic content by TYPO3.

template (Data type: cObject)

This must be loaded with the template-code. Usually this is done with a FILE cObject. If it is not loaded with code, the object returns nothing.

Example:

page.10 = TEMPLATE
page.10 {
   template = FILE
   template.file = fileadmin/template.html
}

This will use the file fileadmin/template.html as template for your website.

subparts.[array] (Data type: array of cObjects)

This is an array of subpart-markers (case-sensitive).

A subpart is defined by two markers in the template. The markers must be wrapped by "###" on both sides. You may insert the subpart- markers inside HTML-comment-tags!

Example:

In the template there is the subpart "HELLO":


This is the HTML code, that will be loaded in the register
and will be replaced with the result...

The following TypoScript code now replaces the subpart "HELLO" with the text given in "value":

page.10.subparts {
  HELLO = TEXT
  HELLO.value = En subpart er blevet erstattet!
}

Note: Before the content objects of each subpart are generated, all subparts in the array are extracted and loaded into the register so that you can load them from there later on.

The register-key for each subparts code is "SUBPART_[theSubpartkey]".

In addition the current-value is loaded with the content of each subpart just before the cObject for the subpart is parsed. That makes it quite easy to load the subpart of the cObject (e.g.: ".current = 1") E.g. this subpart above has the register-key "SUBPART_HELLO".

This is valid ONLY if the property .nonCachedSubst is not set (see below)!

relPathPrefix (Data type: string / properties)

Finds all relative references (e.g. to images or stylesheets) and prefixes this value.

If you specify properties (uppercase) these will match HTML tags and specify alternative paths for them. See example below.

If the property is named "style", it will set an alternative path for the "url()" wrapper that may be in