Core documentation code examples

Language

en

Version

12.1

Description

General TYPO3 CMS code examples. Used in particular for maintaining the official documentation.

Keywords

examples, tutorial, documentation

Copyright

2013-2021

Author

TYPO3 Documentation Team

Email

documentation@typo3.org

License

This document is published under the Open Content License available from http://www.opencontent.org/opl.shtml

Rendered

Wed, 21 May 2025 08:50:37 +0000

Introduction

What does it do?

This extension contains a lot of code samples that are used throughout the TYPO3 Core Documentation. The goals are two-fold:

  1. Provide an easy way for users to gain access to these examples for their own use.
  2. Store all code examples and content elements in a central place, so that it is easier for documentation maintainers to reproduce the examples from the documentation, in particular when refreshing the screenshots.

The usage of these examples is not explained in this manual. It is explained in the relevant documentation.

Not all code examples from the Core Documentation will be moved here as it is a rather huge task. Whenever possible code samples are taken from the TYPO3 Core itself. Furthermore priority is given to those code samples that are related to screenshots.

Backend Module

The extension introduces a backend module with different pages that introduce one concept each:

Page Tree

The extension initializes a page tree with custom content elements that introduce further concepts. Currently it contains only one dummy page, but should in perspective contain all custom pages and content needed for the documentation and not provided by other official TYPO3 distributions like EXT:introduction or EXT:styleguide. The latter are not primarily used for documentation.

An export preset "Examples Export Preset" is included in the dataset to export the page tree repeatedly during the development of the distribution, i.e. when having added a new page or content element. Read the manual "Creating a new distribution" for more information on how to reliably export page trees.

Page Tree Examples

Content element example

Data processor examples

RTE Configuration

Extending TCA

Credits

Some of the examples were originally created by Kasper Skårhøj.

Users manual

If you install this extension, a lot of changes will happen to your TYPO3 backend. Thus you should take care to install it only in a development environment, as you may otherwise run into some surprises.

In various parts of the code contained in this extension, you will find PHP comments that look like this:

// USAGE: TCA Reference > Additional $TCA features
Copied!

This points to which manual (and which part of the manual) refers to the given code sample. This will help you find where to find the related explanations.

For maintainers

Most of the customizations provided by the code samples contained in this example are activated by default. So don't be surprised if you find strange things here and there in your TYPO3 backend.

Whenever possible, the usage of a given piece of code is described in the source code with the following type of PHP comments

// USAGE: Core APIs > TYPO3 API overview > Various examples > Support for custom tables in the Page module
Copied!

This makes it easier to relate a given code sample to a precise place in a manual. The other way round, it should possible to search for a chapter title in the source code and find the relevant code sample.

Code quality

To ensure code quality, some Composer scripts are available. These are run in a Docker container to ensure the same checks as the GitHub action.

composer check
Run all checks
composer check:composer
Run all checks regarding composer.json
composer check:composer:config
Check if composer.json is normalized
composer check:php
Run all checks regarding PHP
composer check:php:cs
Check coding standards
composer check:php:lint
Lint all PHP files
composer fix
Run all fixes
composer fix:composer
Normalize composer.json
composer fix:php
Run all PHP fixes
composer fix:php:cs
Fix coding standard violations

Error handling demonstration

The extension provides a simple FE plugin for demonstrating error handling output in the FE. The settings related to the error handler should be changed to provide different output. It seems hard to get all the possible output, support for all possible settings may be buggy in the Core or has changed over the past and documentation should be adapted accordingly.

Flash messages demonstration

The extension's BE module provide a screen for outputting Flash messages. Code extracts are used in Core APIs.

Flash messages produced by the "Examples" BE module