Issue Feature Rejected

#95629Provide ViewHelper for PageTitleAPI

Jonas Eberle 10/13/21, 14:19 updated 11/06/21, 12:11

Description

The PageTitleAPI works great for any kind of pages or records and is used by many extensions.

For SEO and accessiblity reasons it makes sense to output an

in the main page layout, but to my knowledge we don’t have an out-of-the-box way to use the PageTitle value in a Fluid template.

A ViewHelper could look like this:

use TYPO3\CMS\Core\PageTitle\PageTitleProviderManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

class PageTitleViewHelper extends AbstractViewHelper
{
    public static function renderStatic(
        array $arguments,
        \Closure $renderChildrenClosure,
        RenderingContextInterface $renderingContext
    ) {
        return GeneralUtility::makeInstance(PageTitleProviderManager::class)->getTitle();
    }
}

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.