[TYPO3-core] RFC: #14860: Pagerenderer - use better method for adding meta tags
Ernesto Baschny [cron IT]
ernst at cron-it.de
Fri Jun 25 08:25:39 CEST 2010
Jigal van Hemert schrieb am 25.06.2010 08:15:
> Steffen Kamper wrote:
>> atm meta tags are added with complete html tag.
>> The better method would be to add tags with a name and the content.
>
> Attached version 2 with:
> - CGL on comments (space after //)
> - use of API functions t3lib_div::isFirstPartOfStr(), t3lib_div::inArray()
> - meaningful variable names $additionalAttributes, $attributeName,
> $attributeValue
>
> +1 by reading and testing (version 2)
I prefer the method with this signature:
function addMetaTag($name, $content = '', $isHttpEquiv = FALSE, array
$additionalParameters = array())
So you always use the $name + $content parameters and set $isHttpEquiv
to TRUE if you want a http-equiv instead of a name:
Steffens examples:
$pageRenderer->addMetaTag('author', 'John Doe');
=>
<meta name="author" content="John Doe" />
$pageRenderer->addMetaTag('robots', 'noindex');
=>
<meta name="robots" content="noindex" />
$pageRenderer->addMetaTag('refresh', '5; URL=http://www.example.org/',
TRUE);
=>
<meta http-equiv="refresh" content="5; URL=http://www.example.org/" />
$pageRenderer->addMetaTag('DC.format', 'text/html', FALSE,
array('scheme' =>
'DCTERMS.IMT');
=>
<meta name="DC.format" content="text/html" scheme="DCTERMS.IMT">
> @Olli : this one would be a great candidate for a unit test, but it
> doesn't return anything. How can that be handled???
You check if the meta tag is there as expected in the rendered page.
Cheers,
Ernesto
More information about the TYPO3-team-core
mailing list