2017

  • Please contribute!

2017-1 Extract TypoScript templates from database and save as files

by Martin Bless, 2017-04-05 21:15:00

Keywords:
Extract TypoScript
Task:

You are dealing with an older TYPO3 installation that has TypoScript templates in the database. You prefer to have the templates stored as files in the filesystem.

How can you extract the templates easily and store them as files?

Solution:
Download this extension and follow the instructions: https://github.com/marketing-factory/mfc_tsextract
Credits:
Thank you, Marketing Factory, for making your solution publicly available.

2017-2 Fluid inline syntax: How to pass arguments to viewhelpers

by Riccardo De Contardi, 2017-05-12 10:07:00

Keywords:
Fluid, inline-syntax, Extbase, viewhelper
Problem:

People tend to translate viewhelper calls badly to inline form.

Consider this example:

<my:viewhelper string="{myVar}" />
Bad:

Very often you can find this translated like so:

{my:viewhelper(string: '{myVar}')}

What's wrong with this? While this may work it creates an extra, superfluous TextNode around the variable accessor. And it can easily lead to warnings and errors.

Good:

The clean and correct solution is to avoid the single quotes that create the TextNode. The curly braces are then dropped as well:

{my:viewhelper(string: myVar)}

Pretty easy and well readable!

References:
Credits:
Claus Due

2017-3 Custom FAL inline overlay palette in BE

by Joerg Kummer, 2017-05-15 13:30:00

Keywords:
image, FAL, TCA
Description:
Add custom FAL overlay palettes, to get custom configuration on any FAL related TCA fields.
Custom palette:

Add your custom definition of palette to existing sys_file_reference palettes (default: basicoverlayPalette, imageoverlayPalette, audioOverlayPalette, videoOverlayPalette). my_sitepackage/Configuration/TCA/Overrides/sys_file_reference.php:

<?php
if (!defined('TYPO3_MODE')) die ('Access denied.');

$GLOBALS['TCA']['sys_file_reference']['palettes']['imageOverlayPaletteWithoutLink'] = array(
    'showitem' => '
            title,alternative,--linebreak--,
            description,--linebreak--,crop'
);
Apply palette:

Use columnsOverrides to apply custom palette to any existing FAL related TCA field, for example, tt_content.image my_sitepackage/Configuration/TCA/Overrides/tt_content.php:

<?php
if (!defined('TYPO3_MODE')) die ('Access denied.');

$GLOBALS['TCA']['tt_content']['types']['image']['columnsOverrides']['image']['config']['foreign_types'] = array(
    '0' => array(
        'showitem' => '
            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageOverlayPaletteWithoutLink,
            --palette--;;filePalette'
    ),
    '1' => array(
        'showitem' => '
            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageOverlayPaletteWithoutLink,
            --palette--;;filePalette'
    ),
    '2' => array(
        'showitem' => '
            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageOverlayPaletteWithoutLink,
            --palette--;;filePalette'
    ),
    '5' => array(
        'showitem' => '
            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageOverlayPaletteWithoutLink,
            --palette--;;filePalette'
    )
);

foreign_types 3 & 4 are for audio and video file types

2017-4 Using the TYPO3 API for debugging

by Franz Kugelmann, 2017-06-19 09:21:00

Keywords:
debugging, Extbase
Task:
You want to nicely display the contents of a PHP variable at runtime when using the TYPO3 API..
Solution:

Make use of the class DebugUtility.

DebugUtility::debug()

The DebugUtility::debug() function works nicely in the frontend and backend. Example:

// ((good example should be added here))
\TYPO3\CMS\Core\Utility\DebugUtility::debug($yourVariable);

DebugUtility::var_dump()

The DebugUtility::var_dump() function is specifically optimized to reveal Extbase's object structures. Example:

// ((good example should be added here))
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($yourVariable,
   [checkForHelpfulAdditionalParameters])
References:

2017-5 ... ((template for the next snippet))

by Your Name, 2017-mm-dd hh:mm:ss

Keywords:
abc, bcd, cde
Abc:
...
Bcd:
...
and:
...
so:
...
on:
...