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

时间:2013-11-06 12:28:48

标签: 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文件放在哪里?我应该如何在Fluid模板中包含这个css?

2 个答案:

答案 0 :(得分:4)

请记住,如果您在许多页面上使用插件,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

答案 1 :(得分:3)

根据经验,你将JS和CSS文件放入你的typoscript。

示例:

page = PAGE
page {
  includeCSS {
    myfile = path/to/my/file.css
  }

  includeJS {
    myfile = path/to/my/file.js
  }
}

这带来了一些好处;您可以在多个文件中组织js和css,并通过设置TYPO3连接并压缩它们

config {
  concatenateJs = 1
  concatenateCss = 1

  compressJs = 1
  compressCss = 1
}

在此处查看更多内容:http://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Page/Index.html