Typo3 Fluid 模板无法使用 uri.resource 找到 css 文件

标签 typo3 fluid

我关注了this tutorial使用 Fluid 模板创建 Typo3 网站。但是,我无法将 CSS 包含在模板中。在标签中包含以下 css:

<link rel="stylesheet" href="css/bootstrap.css">

我在模板中将其重写为:

<link rel="stylesheet" href="{f:uri.resource(path:'css/bootstrap.css')}">

但不包括 css。模板的路径是:

fileadmin/templates/layouts/main.html

CSS 文件的路径是:

fileadmin/templates/css/bootstrap.css

我应该把 CSS 文件放在哪里?我应该如何将此 CSS 包含在 Fluid 模板中?

最佳答案

请记住,如果您在许多页面上使用插件,pduerseler 的做法会更好。

至于您的问题,uri.resource ViewHelper 假定您的资源位于扩展的 Resources/Public 目录中。所以:

<link rel="stylesheet" href="{f:uri.resource(path:'css/bootstrap.css')}">

指向

typo3conf/ext/yourExt/Resources/Public/css/bootstrap.css

无法使用资源 ViewHelper 指向 fileadmin 中的文件,请参阅 https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/typo3/sysext/fluid/Classes/ViewHelpers/Uri/ResourceViewHelper.php .

目前 TYPO3 页面模板的最佳实践是在自己的扩展中拥有 TYPO3 网站的模板,参见例如https://github.com/georgringer/modernpackage

关于Typo3 Fluid 模板无法使用 uri.resource 找到 css 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19812157/

相关文章:

composer-php - 在 TYPO3 8.7 中,composer install 将typo3和index.php安装为目录和文件,而不是符号链接(symbolic link)

typo3 - 如何从 TypoScript 调用 extbase 操作

typo3 - 更改 TYPO3 扩展 tx_news 中 Flexform 选择项的标签

TYPO3 TCA 选择,项目数组中的 NULL 值

TYPO3 Extbase switchableControllerActions

jquery - 在现有页面上实现流体设计

php - 从 Controller 中的 FlexForms 获取 TYPO3 插件设置

php - TYPO3 扩展库 : setDefaultOrderings in Controller

typo3 - 在 extbase/fluid 中使 imagefield 成为必需的

TYPO3:将多个参数传递给流体模板中的局部变量