Templating manual · Introduction · Portable code

1.6 Portable code

Fluid Powered TYPO3 encourages portable code by using an extension to package your templates. Because of this you are encourage to follow a few simple measures to ensure your code is as transparent as possible. The recommendations are:

Proper and specific dependencies

Set your extension to depend on a specific version of VHS and Flux (or one or both of the feature extensions fluidcontent, fluidpages etc.) in order to receive a warning before unintentionally updating either extension to a version not supported. Our release schedules mean that you should limit the dependency to the next major version because major versions is where we introduce possible breaking changes which require migration. A concrete example: if your provider extension depends on ViewHelpers from VHS version 1.8.5, your maximum allowed version of VHS as stated in your dependency list should be 1.9.99 because then if the extension manager some day presents you with VHS version 2.0.0 available for update, it will warn you that your provider extension may no longer be able to function.

No hardcoding!

Avoid hardcoded values - no page UID values directly in template, no hardcoded language labels and no setup-specific values such as group UIDs, storage PIDs and page UIDs in TypoScript constants files.

Templates, Assets, Fonts, Configuration storage

Place all files - templates as well as assets (CSS, JS, web fonts, icons, CSS framework files and such) in your provider extension so that they can be version controlled and managed in a single place.

Compatibility is sometimes necessary

Even if your extension uses namespace PHP classes and is intended to run only on 6.0 and above it is good practice to add a Migrations/Code/ClassAliasMap.php file for at least your controller classes. Many third-party extensions may not be namespace aware and you should enable those to still detect your controller class by the old style class name. ViewHelpers, services and such are less important to alias map.

Avoid the deprecated pieces

Avoid deprecated ViewHelpers even if they currently function on your site. TYPO3 has a very long deprecation period for features - VHS has a shorter one. To know if any of your templates are using ViewHelpers which are deprecated in the versions of the TYPO3 core, VHS or Fluid (or indeed any extension!) you can use the builder extension to scan your Fluid templates for deprecations.

By observing these simple suggestions you ensure that your provider extension will be maintenance free for as long as possible, that it will also function when installed on another site and that all assets will follow along, in the correct versions required by the provider extension's templates.

Continue: Chapter 1.8: Development companion extensions.

Jump to...