TYPO3 v15 dev-main snapshot ()
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Fluid\ViewHelpers\Page;
|
||||
|
||||
use TYPO3\CMS\Core\Page\PageRenderer;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* ViewHelper to add various content before the closing body-tag of the current page using PageRenderer.
|
||||
*
|
||||
* ```
|
||||
* <f:page.footerData>
|
||||
* <script>
|
||||
* var _paq = window._paq = window._paq || [];
|
||||
* _paq.push(['trackPageView']);
|
||||
* _paq.push(['enableLinkTracking']);
|
||||
* (function() {
|
||||
* var u = "https://your-matomo-domain.example.com/";
|
||||
* _paq.push(['setTrackerUrl', u + 'matomo.php']);
|
||||
* _paq.push(['setSiteId', '1']);
|
||||
* var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
|
||||
* g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
|
||||
* })();
|
||||
* </script>
|
||||
* </f:page.footerData>
|
||||
* ```
|
||||
*
|
||||
* @see https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-page-footerdata
|
||||
*/
|
||||
final class FooterDataViewHelper extends AbstractViewHelper
|
||||
{
|
||||
public function __construct(private readonly PageRenderer $pageRenderer) {}
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
$this->pageRenderer->addFooterData($this->renderChildren());
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Fluid\ViewHelpers\Page;
|
||||
|
||||
use TYPO3\CMS\Core\Page\PageRenderer;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* ViewHelper to add various content in the head section of the current page using PageRenderer.
|
||||
*
|
||||
* ```
|
||||
* <f:page.headerData>
|
||||
* <link rel="preload" href="/fonts/myfont.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
||||
* <link rel="dns-prefetch" href="//example-cdn.com">
|
||||
* <link rel="preconnect" href="https://example-cdn.com">
|
||||
* </f:page.headerData>
|
||||
* ```
|
||||
*
|
||||
* @see https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-page-headerdata
|
||||
*/
|
||||
final class HeaderDataViewHelper extends AbstractViewHelper
|
||||
{
|
||||
public function __construct(private readonly PageRenderer $pageRenderer) {}
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
$this->pageRenderer->addHeaderData($this->renderChildren());
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Fluid\ViewHelpers\Page;
|
||||
|
||||
use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* ViewHelper to set meta tags from Fluid templates.
|
||||
*
|
||||
* ```
|
||||
* <f:page.meta property="description">My page description</f:page.meta>
|
||||
* <f:page.meta property="og:title">My article title</f:page.meta>
|
||||
* <f:page.meta property="og:image" subProperties="{width: 1200, height: 630}">/path/to/image.jpg</f:page.meta>
|
||||
* ```
|
||||
*
|
||||
* @see https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-page-meta
|
||||
*/
|
||||
final class MetaViewHelper extends AbstractViewHelper
|
||||
{
|
||||
public function __construct(private readonly MetaTagManagerRegistry $metaTagManagerRegistry) {}
|
||||
|
||||
public function initializeArguments(): void
|
||||
{
|
||||
$this->registerArgument('property', 'string', 'The meta property name (e.g. "description", "og:title")', true);
|
||||
$this->registerArgument('type', 'string', 'The meta type attribute (name, property, http-equiv). If not set, the appropriate manager will determine the type.');
|
||||
$this->registerArgument('subProperties', 'array', 'Array of sub-properties for complex meta tags (e.g. og:image width/height)', false, []);
|
||||
$this->registerArgument('replace', 'bool', 'Replace existing meta tags with the same property', false, false);
|
||||
}
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
$property = $this->arguments['property'];
|
||||
$content = $this->renderChildren();
|
||||
|
||||
if ($content === null || $content === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$metaTagManager = $this->metaTagManagerRegistry->getManagerForProperty($property);
|
||||
|
||||
$metaTagManager->addProperty(
|
||||
$property,
|
||||
(string)$content,
|
||||
$this->arguments['subProperties'],
|
||||
$this->arguments['replace'],
|
||||
$this->arguments['type'] ?? ''
|
||||
);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Fluid\ViewHelpers\Page;
|
||||
|
||||
use TYPO3\CMS\Core\PageTitle\RecordTitleProvider;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* ViewHelper to set the page title from Fluid templates.
|
||||
*
|
||||
* ```
|
||||
* <f:page.title>My Custom Page Title</f:page.title>
|
||||
* ```
|
||||
*
|
||||
* @see https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-page-title
|
||||
*/
|
||||
final class TitleViewHelper extends AbstractViewHelper
|
||||
{
|
||||
public function __construct(private readonly RecordTitleProvider $pageTitleProvider) {}
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
$title = $this->renderChildren();
|
||||
if ($title !== null) {
|
||||
$this->pageTitleProvider->setTitle((string)$title);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user