我关注了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/