undkonsorten / meta-tag
提供用于在TYPO3 CMS中设置元标签的Fluid视图助手
1.0.0
2019-03-22 15:11 UTC
Requires
- php: ^7.2
- typo3/cms-core: ^9.5
Requires (Dev)
- nimut/testing-framework: ^4.0
Replaces
- meta_tag: 1.0.0
This package is auto-updated.
Last update: 2024-09-23 03:42:15 UTC
README
允许在Fluid中编写您的元标签的TYPO3扩展。语法尽可能地接近HTML <meta>
标签。包含一个级别的覆盖。
安装
通过composer
composer require undkonsorten/meta-tags
或从 Github
配置
不需要配置,无需包含TypoScript。
使用方法
要在您的Fluid模板中使用视图助手,您必须导入命名空间,例如。
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:m="http://typo3.org/ns/Undkonsorten/MetaTag/ViewHelpers"
data-namespace-typo3-fluid="true">
或
{namespace m=Undkonsorten\MetaTag\ViewHelpers}
然后您可以使用以下任何形式的meta视图助手
<!--Tag style-->
<m:meta http-equiv="content-type" content="{settings.contentType}" />
<!--Inline style-->
{m:meta(property:'og:description',content:description)}
<!--You can omit content attribute and use tag content instead-->
<m:meta property="og:image"><f:uri.image image="{image}" width="800" height="600" absolute="1" /></m:meta>
<!--The same works for inline syntax-->
{author.fullName -> m:meta(name:'author')}
如果内容为空(即只有空白字符),则不会添加元标签。无需将每个元标签都包裹在if构造中,只是为了删除空白的标签。
覆盖
如果有请求的元标签与现有的元标签发生冲突(相同的 property
/ name
/ http-equiv
值),则保留现有的一个,并将新的一个丢弃。要更改此行为,您可以设置 override="1"
。然后,任何现有相同类型的元标签都将被覆盖。
这意味着您有一个两级层次结构,它在运行时无论处理顺序如何都会工作。只需定义您的“全局”元标签,例如,来自pages
记录,不使用覆盖,但为更具体的设置标志,例如来自扩展显示操作。