3

我按照本教程使用 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?

4

2 回答 2

4

Please keep in mind that pduerseler's way of doing it is better if you're using a plugin on many pages.

As for your problem, the uri.resource ViewHelper assumes that your resources are in the Resources/Public directory of your extension. So:

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

points to

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

It is not possible to point to a file in fileadmin with the resource ViewHelper, see https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/typo3/sysext/fluid/Classes/ViewHelpers/Uri/ResourceViewHelper.php.

Current best practise for a TYPO3 page template is to have the template of a TYPO3 Website in an own extension, see e.g. https://github.com/georgringer/modernpackage

于 2013-11-06T12:44:53.493 回答
3

根据经验,您将 JS 和 CSS 文件放入您的打字稿中。

例子:

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

于 2013-11-06T12:32:26.680 回答