Displaying content on multiple pages

Using this TypoScript code, you can display the content of a content element on multiple pages of a website.

If you want to display a content element on multiple pages of a website, you have two options:

In the TYPO3 backend you can use a content element of type Insert records. With a file browser, you select a content element as the 'source' and thus set a reference to it. This means that any change in the source element will also be done on the page that references the element. This method applies very well when there are only a few locations at which the source element is to be inserted.

The second and more flexible option is to use a tiny TypoScript snippet to automatically insert the content element on multiple pages. This can be done like this:

Getting the content of an element TypoScript, SETUP section
temp.xyz = RECORDS
temp.xyz {
    tables = tt_content
# Content element with ID 42 is the source
    source = 42
}

TYPO3 stores the content elements of pages in the database table "tt_content". Each record in this table can be referenced by a unique ID (field uid). With the TypoScript code above, we directly access this table and fetch the content of the element with the ID 42. That way, we can include any content element on many — even all — pages of a website.

The ID of a content element can be found in the TYPO3 backend by moving the mouse over the icon next to the type (e.g. 'Text only') of the respective element. Within a content element, the ID is displayed in the upper area (just below the 'Save' button). In newer TYPO3 versions you can find the ID in the lower right corner of the content element.

To avoid that content included this way appears twice on the page where it has been defined, it is generally advisable to create a separate page for these elements. The separate page should have a speaking name like "Reusable content elements" and be set to "Hide in menu" in its page properties.

Finally, the object temp.xyz can be assigned to a marker in a HTML template to display the content on the website.