如何将 html 模板集成到 typo3

How to integrate a html template to typo3

我是 typo3 的新手,我想在其中集成我的 HTML 模板。但我无法将我的内容添加到页面,我得到的只是一个空白页面。

我正在使用 TYPO3 v8

您好!

TYPO3 8模板整合步骤

TYPOSCRIPT

告诉 TYPO3 应该从哪里获取模板。

page = PAGE
page.10 {
    templateRootPaths {
       10 = PATH TO YOUR TEMPLATES
    }
    layoutRootPaths {
       10 = PATH TO YOUR LAYOUTS
    }
    partialRootPaths {
       10 = PATH TO YOUR PARTIALS
    }
    templateName = TEXT
    templateName.stdWrap {
        cObject = TEXT
        cObject {
            data = levelfield:-2,backend_layout_next_level,slide
            override.field = backend_layout
            split {
                token = pagets__
                1.current = 1
                1.wrap = |
            }
        }
        ifEmpty = Home
     }
}

布局

创建布局不是必需的,但我建议您创建布局,如果您只有一种类型的模板也是如此。

布局(在TYPO3中称为后端布局)可以在TYPO3后端创建,后端布局保存在数据库中。但是您可以将后端布局配置保存在文件中。

Hint: Try save the backend layouts configuration in files so you can add to git

后端布局配置示例:

mod.web_layout.BackendLayouts {
    Home # identified by this name { 
        title = Home # this is shown in backend when you select the layout
        icon = EXT:example_extension/Resources/Public/Images/BackendLayouts/default.gif
        config {
            backend_layout {
                colCount = 1
                rowCount = 1
                rows {
                    1 {
                        columns {
                            1 {
                                name = Content
                                colPos = 1 # this is important, i'm talking about colPos below
                            }
                        }
                    }
                }
            }
        }
    }
}

ColPos meaning: you can have multiple columns in a layout, and the colPos is used to render the content in frontend. This is what will be used later in template <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: 1}" />

The above configuration should be included in PageTs. This is found if you edit a page and go to Resources tab.

lib.dynamicContent

的拼写配置
lib.dynamicContent = COA
lib.dynamicContent {
    5 = LOAD_REGISTER
    5 {
        colPos.cObject = TEXT
        colPos.cObject {
            field = colPos
            ifEmpty.cObject = TEXT
            ifEmpty.cObject {
                value.current = 1
                ifEmpty = 0
            }
        }
        pageUid.cObject = TEXT
        pageUid.cObject {
            field = pageUid
            ifEmpty.data = TSFE:id
        }
        contentFromPid.cObject = TEXT
        contentFromPid.cObject {
            data = DB:pages:{register:pageUid}:content_from_pid
            data.insertData = 1
        }
        wrap.cObject = TEXT
        wrap.cObject {
            field = wrap
        }
        maxItems.cObject = TEXT
        maxItems.cObject {
            field = maxItems
            ifEmpty =
        }
    }
    20 = CONTENT
    20 {
        table = tt_content
        select {
            includeRecordsWithoutDefaultTranslation = 1
            orderBy = sorting
            where = {#colPos}={register:colPos}
            where.insertData = 1
            pidInList.data = register:pageUid
            pidInList.override.data = register:contentFromPid
            max.data = register:maxItems
            // select.languageField setting is needed if you use this typoscript in TYPO3 < v7
            // languageField = sys_language_uid
        }
        stdWrap {
            dataWrap = {register:wrap}
            required = 1
        }
    }
    90 = RESTORE_REGISTER
}
lib.dynamicContentSlide < lib.dynamicContent
lib.dynamicContentSlide.20.slide = -1

lib.dynamicContentFirst < lib.dynamicContent
lib.dynamicContentFirst.20.select.max = 1

首页布局html整合

<f:render section="main" />

主页模板整合

<f:layout name="Home" />
<f:section name="content">
  // content
  <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: 1}" />
</f:section>

现在我们已经设置了布局和模板。希望你有一个 TYPO3 的基本设置(至少一个根页面和一个模板设置)

如果您还没有此设置,请按照以下步骤操作:

  1. 创建根页面
  2. 使用根页面上的列表
  3. 创建模板记录 - 进入选项选项卡并选中 Clear -> ConstantsClear -> setup 并选中 Rootlevel
  4. 进入 Includes 选项卡并从多个 select 框 select fluid_styled_content
  5. 在创建的模板中粘贴 TYPOSCRIPT configuration(选中“常规”选项卡)

编辑根页面并转到外观选项卡以 select 后端布局。