簡體   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