繁体   English   中英

完全控制TYPO3的HTML输出

[英]Complete control over HTML output from TYPO3

我正在TYPO3中建立一个使用AngularJS的网站。 为了获得正确的CSS类,我需要编辑<body>标签。 我还希望完全控制模板中的HTML输出。

我当前的尝试是使用从后端配置的模板:

page = PAGE
page.10 = TEMPLATE
page.10.template = FILE
page.10.template.file = fileadmin/Template/index.html

这将输出以下HTML:

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">
<!-- 
    This website is powered by TYPO3 - inspiring people to share!
    TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
    TYPO3 is copyright 1998-2014 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
    Information and contribution at http://typo3.org/
-->

<title>My site - Title from Typo3</title>
<meta name="generator" content="TYPO3 6.2 CMS">

<link rel="stylesheet" type="text/css" href="typo3temp/stylesheet_8b9c2e8d89.css?1418032603" media="all">

</head>
<body>

<!-- HTML basics -->
<!-- My template start here -->
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="ie lt-ie9 lt-ie8 lt-ie7" ng-app="app"> <![endif]-->
<!--[if IE 7]>         <html class="ie lt-ie9 lt-ie8" ng-app="app"> <![endif]-->
<!--[if IE 8]>         <html class="ie lt-ie9" ng-app="app"> <![endif]-->
<!--[if gt IE 8]><!--> <html ng-app="app"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>My site - Title from template</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" CONTENT="noindex, nofollow">

文档中的“ 模板”指南不会告诉您高级内容,例如将整个模板切换为其他内容。

  • 我可以为此使用扩展名吗?
  • 我可以为模板创建扩展吗?
  • 我的模板如何在添加内容的地方创建TYPO3占位符?

我想将我的模板和CSS / Javascript存储在存储库中,而不在后端GUI(数据库)中进行配置。

相关问题: TYPO3集成HTML

代替阅读Getting Started Guide ,您应该尝试Templating Tutorialhttp : //docs.typo3.org/typo3cms/TemplatingTutorial/

您可以将所有TS排除到文件中,并且仅将其包含在一个模板记录中。 这就是Introduction Package所做的。 http://docs.typo3.org/typo3cms/TyposcriptSyntaxReference/Syntax/Includes/Index.html

对于“对模板的完全控制”问题,还有另一种鲜为人知的解决方案

http://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#pagerenderertemplatefile

config.pageRendererTemplateFile = my/path/template.html

然后,您可以从typo3 / sysext / tslib / template / tslib_page_frontend.html复制模板,然后根据需要进行编辑,例如

###XMLPROLOG_DOCTYPE###
<!--[if lt IE 7 ]> <html lang="de" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]>    <html lang="de" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="de" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="de" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> 
  <html lang="de" class="no-js"> 
<!--<![endif]-->
###HEADTAG###

###METACHARSET###
###INLINECOMMENT###

###BASEURL###
###SHORTCUT###
###TITLE###
###META###

###CSS_INCLUDE###
###CSS_INLINE###

###JS_LIBS###
###JS_INCLUDE###
###JS_INLINE###

###HEADERDATA###
</head>
###BODY###
###JS_LIBS_FOOTER###
###JS_INCLUDE_FOOTER###
###JS_INLINE_FOOTER###
###FOOTERDATA###
</body>
</html>

如果这确实很健壮(我在一个站点上有并且没有问题),那么与config.disableAllHeaderCode相比,优点是-例如-您仍然可以获取默认的JS,例如config.spamProtectEmailAddresses的解密功能config.spamProtectEmailAddresses ,您还必须手动添加。

要输出RSS提要,我也希望使用config.disableAllHeaderCode ,但是如果要输出HTML文档,这可能是一个可行的选择。

我可以为模板创建扩展吗?

现在,将模板保留在扩展中是一种好习惯。 我个人仍然在fileadmin/templates/myproject有它们

我的模板如何在添加内容的地方创建TYPO3占位符?

请参考@pgampe答案中的链接。 您可以直接从FLUIDTEMPLATE开始,因此您将学习最新的模板语言。 必须阅读一些基本文档才能开始使用TYPO3。

我想将我的模板和CSS / Javascript存储在存储库中,而不在后端GUI(数据库)中进行配置。

您是对的,这也是最佳做法,请参阅@pgampe的链接。 在数据库中,您只有。

<INCLUDE_TYPOSCRIPT: source="FILE:fileadmin/templates/main/ts/config.ts"> 

甚至(我正确吗?):

<INCLUDE_TYPOSCRIPT: source="FILE: EXT:mytemplateext/path/to/config.ts">

等等。 包括TypoScript也适用于Page TSConfig和User TSConfig。 我不想以任何其他方式工作!

您还需要获得代码在这里为着色你最喜欢的编辑器,例如,用于崇高: https://sublime.wbond.net/packages/TypoScript

您无需创建任何扩展名,因为可以使用TypoScript(设置字段)轻松禁用它。

config.disableAllHeaderCode = 1

@查看文档

当然,在这种情况下,您需要将所有标头添加到模板中。

当您要通过bootsrtap从包含在指定typeNum Extbase ext渲染纯JSON(或其他数据)时,此标志也很有用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM