Project

General

Profile

Actions

Feature #95629

closed

Provide ViewHelper for PageTitleAPI

Added by Jonas Eberle about 3 years ago. Updated about 3 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
SEO
Target version:
-
Start date:
2021-10-13
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

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 <h1> 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();
    }
}
Actions

Also available in: Atom PDF