简体   繁体   English

Typo3 v9.5LTS部分不渲染

[英]Typo3 v9.5LTS partial not rendering

Trying to understand the right way to do templating in typo3, I came from typo3 6.2 to typo3 v9.5 and everything is new. 为了理解在typo3中进行模板制作的正确方法,我从typo3 6.2到typo3 v9.5,一切都是新的。 I've achieved to use DCE, create a backend layout, and now I'm trying to create a repetitive element to use on multiple pages with different templates for instance. 我已经实现了使用DCE的能力,创建了后端布局,现在我试图创建一个重复元素,以在具有不同模板的多个页面上使用。

Comparing with a fresh typo3 installation with the main template provided with typo3, I can see they use a file inside : 与带有typo3随附的主模板的全新typo3安装相比,我可以看到它们在其中使用了一个文件

ext/your_template/Resources/Private/Partials/Page/Structure/Footercontent ext / your_template /资源/私人/部分/页面/结构/页脚内容

Then in the template, they render the html file that loads the elements from the home template (I guess). 然后在模板中,他们呈现html文件,该文件从主模板加载元素(我想)。

Here you can see the render 在这里您可以看到渲染

My problem comes when I try to replicate this in my own page. 当我尝试在自己的页面中复制此问题时,就会出现问题。 It doesn't render in my page, not even the html base structure. 它不会在我的页面中呈现,甚至不会在html基本结构中呈现。

FooterContent.html inside as I show in this picture and the render call in my main template like in this picture 我在这张图片中显示的是 FooterContent.html 而在主模板中的渲染调用则如图所示

Home.html (Template) Home.html(模板)

  <f:section name="Footer">

      <f:render partial="Structure/FooterContent" arguments="{_all}" />

  </f:section>

FooterContent.html FooterContent.html

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<section class="section footer-section footer-section-content">
  <div class="beez_footer">
    <div class="beez_footer_top beez_section">
      <div class="beez_ft_left">
        <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '5'}" />
      </div>
      <div class="beez_ft_right">
        <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '6'}" />
      </div>
    </div>
    <div class="beez_footer_middle beez_section">
      <div class="beez_ft_left">
        <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '7'}" />
      </div>
      <div class="beez_ft_middle">
        <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '8'}" />
      </div>
      <div class="beez_ft_right">
        <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '9'}" />
      </div>
    </div>
    <div class="beez_footer_bottom beez_section">
      <div class="beez_ft_left">
        <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '10'}" />
      </div>
      <div class="beez_ft_right">
        <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: 11}" />
      </div>
    </div>
  </div>
</section>
</html>

setup.typoscript in (ext/your_template/Configuration/Typoscript/): (ext / your_template / Configuration / Typoscript /)中的setup.typoscript:

######################
#### DEPENDENCIES ####
######################
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript">


################
#### HELPER ####
################
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:nubis_theme/Configuration/TypoScript/Helper/DynamicContent.typoscript">


##############
#### PAGE ####
##############
page = PAGE
page {
    typeNum = 0
    shortcutIcon = EXT:nubis_theme/Resources/Public/Icons/favicon.ico

    10 = FLUIDTEMPLATE
    10 {
        # Template names will be generated automaticly by converting the applied
        # backend_layout, there is no explicit mapping nessesary anymore.
        #
        # BackendLayout Key
        # subnavigation_right_2_columns -> SubnavigationRight2Columns.html
        #
        # Backend Record
        # uid: 1 -> 1.html
        #
        # Database Entry
        # value: -1 -> None.html
        # value: pagets__subnavigation_right_2_columns -> SubnavigationRight2Columns.html
        templateName = TEXT
        templateName {
            cObject = TEXT
            cObject {
                data = pagelayout
                required = 1
                case = uppercamelcase
                split {
                    token = pagets__
                    cObjNum = 1
                    1.current = 1
                }
            }
            ifEmpty = Default
        }
        templateRootPaths {
            0 = EXT:nubis_theme/Resources/Private/Templates/Page/
            1 = {$page.fluidtemplate.templateRootPath}
        }
        partialRootPaths {
            0 = EXT:nubis_theme/Resources/Private/Partials/Page/
            1 = {$page.fluidtemplate.partialRootPath}
        }
        layoutRootPaths {
            0 = EXT:nubis_theme/Resources/Private/Layouts/Page/
            1 = {$page.fluidtemplate.layoutRootPath}
        }
        dataProcessing {
            10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
            10 {
                references.fieldName = media
            }
            20 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
            20 {
                levels = 2
                includeSpacer = 1
                as = mainnavigation
            }
        }
    }

    meta {
        viewport = {$page.meta.viewport}
        robots = {$page.meta.robots}
        apple-mobile-web-app-capable = {$page.meta.apple-mobile-web-app-capable}
        description = {$page.meta.description}
        description {
            override.field = description
        }
        author = {$page.meta.author}
        author {
            override.field = author
        }
        keywords = {$page.meta.keywords}
        keywords {
            override.field = keywords
        }
        X-UA-Compatible = {$page.meta.compatible}
        X-UA-Compatible {
            attribute = http-equiv
        }

        # OpenGraph Tags
        og:title {
            attribute = property
            field = title
        }
        og:site_name {
            attribute = property
            data = TSFE:tmpl|setup|sitetitle
        }
        og:description = {$page.meta.description}
        og:description {
            attribute = property
            field = description
        }
        og:image {
            attribute = property
            stdWrap.cObject = FILES
            stdWrap.cObject {
                references {
                    data = levelfield:-1, media, slide
                }
                maxItems = 1
                renderObj = COA
                renderObj {
                    10 = IMG_RESOURCE
                    10 {
                        file {
                            import.data = file:current:uid
                            treatIdAsReference = 1
                            width = 1280c
                            height = 720c
                        }
                        stdWrap {
                            typolink {
                                parameter.data = TSFE:lastImgResourceInfo|3
                                returnLast = url
                                forceAbsoluteUrl = 1
                            }
                        }
                    }
                }
            }
        }
    }

    includeCSSLibs {

    }

    includeCSS {
        nubis_theme_layout = EXT:nubis_theme/Resources/Public/Css/layout.min.css
    }

    includeJSLibs {

    }

    includeJS {

    }

    includeJSFooterlibs {

    }

    includeJSFooter {
        nubis_theme_scripts = EXT:nubis_theme/Resources/Public/JavaScript/Dist/scripts.js
    }
}


################
#### CONFIG ####
################
config {
    absRefPrefix = auto
    contentObjectExceptionHandler = 0
    no_cache = {$config.no_cache}
    uniqueLinkVars = 1
    pageTitleFirst = 1
    linkVars = L
    prefixLocalAnchors = {$config.prefixLocalAnchors}
    renderCharset = utf-8
    metaCharset = utf-8
    doctype = html5
    removeDefaultJS = {$config.removeDefaultJS}
    inlineStyle2TempFile = 1
    admPanel = {$config.admPanel}
    debug = 0
    cache_period = 86400
    sendCacheHeaders = {$config.sendCacheHeaders}
    intTarget =
    extTarget =
    disablePrefixComment = 1
    index_enable = 1
    index_externals = 1
    index_metatags = 1
    headerComment = {$config.headerComment}

    // Disable Image Upscaling
    noScaleUp = 1

    // Compression and Concatenation of CSS and JS Files
    compressJs = 0
    compressCss = 0
    concatenateJs = 0
    concatenateCss = 0
}

Then, inside my website I get only the content I've been able to display from the template. 然后,在我的网站内部,我仅能从模板中显示内容。 In other words, everything except the render partial. 换句话说,除渲染以外的所有内容都是局部的。 I couldn't see any problem related to this and the documentation from typo3 doesn't clarify this. 我看不到与此相关的任何问题,来自typo3的文档也没有对此进行澄清。 I must be missing something but I don't know what. 我一定想念什么,但我不知道。

Edit: Added setup.typoscript (I'm using the default setup provided by when installing the theme package from: https://sitepackagebuilder.com ) 编辑:添加了setup.typoscript(我正在使用从以下位置安装主题包时提供的默认设置: https ://sitepackagebuilder.com)

From the comments the solution should be to add the section to the default page layout file. 从注释中,解决方案应该是将该部分添加到默认页面布局文件中。

By default (from sitepackagebuilder ) a layout file is used, so sections defined in a template must be defined in the layout file. 默认情况下(来自sitepackagebuilder )使用布局文件,因此必须在布局文件中定义模板中定义的部分。

In the default layout file you find only a Section "main" which is rendered. 在默认布局文件中,您只能找到呈现的“主”部分。

To add the Footer section, place a RenderViewHelper somewhere in your layout: 要添加Footer部分,请将RenderViewHelper放置在布局中的某个位置:

<f:render section="Footer" />

If you want to make it optional you can add the attribute optional="true" to the ViewHelper so you dont have to define the Footer Section in every Template if you dont need this. 如果要使其可选,可以将属性optional="true"到ViewHelper,这样就不需要在每个模板中定义页脚节。

The structure of a FLUIDTEMPLATE looks like this: FLUIDTEMPLATE的结构如下所示:

  • Templates can contain Partials and can have Sections Templates可以包含Partials ,也可以包含Sections
  • Partials can contain other Partials Partials可以包含其他Partials
  • Layouts are enclose the Templates can render Sections and can also contain Partials Layouts包含在Templates中, Templates可以呈现Sections ,也可以包含Partials

If you want to render a footer to your global page, place the footer Partial in your Layout file. 如果要向全局页面呈现页脚,请将页脚Partial放置在Layout文件中。 If you want a footer depending on the template used, place the footer in a Section of your template and let render the Section in your Layout . 如果你想有一个页脚取决于所使用的模板,将页脚的Section模板的,让呈现Section在你的Layout

just for clarification of René's answer: 只是为了澄清René的答案:

Fluid Templates: 流体模板:

  • templates - this is the entry into fluid. 模板 -这是进入流体的入口。 if you call fluid, you call a template ( <f:layout name="layoutname" /> ). 如果调用流畅,则调用模板( <f:layout name="layoutname" /> )。 A template can determine a layout; 模板可以确定布局; if it does so, the rendering starts with the layout 如果这样做,则渲染从布局开始

  • layouts - they are meant to give a general structure. 布局 -它们旨在给出总体结构。 This can be achieved by inserting different sections from the determining template and/ or from partials. 这可以通过从确定模板和/或部分插入不同的部分来实现。

  • partials - these are the flexible building blocks your page will be build. 局部 -这些是您页面将要构建的灵活构建块。 everytime you have a block of data which might occur more often, or which is an unit for itself, make a partial from it, so you can reuse it and structure your fluid. 每当您拥有一块数据块时,它可能会更频繁地出现,或者它本身就是一个单位,请从中分离出一部分数据,以便重新使用它并构造流体。

sections can occur in templates and partials as a subblock. 部分可以在模板和局部中作为子块出现。
If you insert sections like <f:render section="sectionname" /> the section is expected to be in the current file - except for layouts, they expect their sections in the template. 如果您插入<f:render section="sectionname" />之类的节,则该节应位于当前文件中-除布局外,他们希望其节在模板中。
If you want to insert a section from another file you only can insert sections from a partial: <f:render section="sectionname" partial="partialname" /> . 如果要从另一个文件插入节,则只能从局部文件中插入节: <f:render section="sectionname" partial="partialname" /> If you ommit the section name you insert the whole partial ( <f:render partial="partialname" /> ) 如果省略节名,则插入整个部分( <f:render partial="partialname" />

In general all insertions with f:render transmit no data (fluid variables), except: a layout gets all data known to the determining template, and a section in the template which is inserted from a layout knows all data of the initial template. 通常,所有带有f:render插入都不会传输任何数据(流体变量),但以下情况除外:布局会获取确定模板已知的所有数据,并且从布局插入的模板中的部分会知道初始模板的所有数据。
For all other insertions you may need to transfer data with the arguments parameter of the f:render viewhelper: 对于所有其他插入,您可能需要使用f:render viewhelper的arguments参数传输数据:

<f:render section="sectionname" arguments="{ind1:'data1', ind2:'data2'}" />

A special case: you can transfer all (localy known) data with arguments="{_all}" 一种特殊情况:您可以使用arguments="{_all}"传输所有(本地已知的)数据

Thanks to René Pflamm and Bernd Wilke for their explanation. 感谢RenéPflamm和Bernd Wilke的解释。 Since I came from tpyo3 v6.2, I used mark records there to repeat the same item over multiple templates with the: 由于我来自tpyo3 v6.2,因此我在此处使用标记记录在多个模板上使用以下命令重复同一项目:

LOGO = RECORDS
LOGO.tables = tt_content
LOGO.source = 1

And then in template 然后在模板中

<div class="myClass">###LOGO###</div>

This allowed me to get some elements from a folder inside typo3 that matched their id. 这使我可以从typo3内的文件夹中获取一些匹配其ID的元素。

I don't know if this can still be used, but I created a simple function 我不知道它是否仍然可以使用,但是我创建了一个简单的函数

(located at ext/your_theme/Configuration/Typoscript/Helper/DynamicContent.typoscript) (位于ext / your_theme / Configuration / Typoscript / Helper / DynamicContent.typoscript)

to use in partials where I call typoscriptObjectPath="lib.dynamicContentFunction" and this allow me to call through data parameters the id of the element I'd like to render. 可以在我调用typoscriptObjectPath="lib.dynamicContentFunction" ,这使我可以通过数据参数调用我要呈现的元素的ID。 Here's an example and the function: 这是一个示例和函数:

<f:cObject typoscriptObjectPath="lib.dynamicContentFunction" data="{Uid: '11'}" />

AND

lib.dynamicContentFunction = COA
lib.dynamicContentFunction {
    5 = LOAD_REGISTER
    5 {
        Uid.cObject = TEXT
        Uid.cObject {
            field = Uid
        }
    }
    20 = CONTENT
    20 {
        table = tt_content
        select {
            includeRecordsWithoutDefaultTranslation = 1
            orderBy = sorting
            where = {#uid}={register:Uid}
            where.insertData = 1
            pidInList = -1
            recursive = 99
        }
        stdWrap {
            dataWrap = {register:wrap}
            required = 1
        }
    }
    90 = RESTORE_REGISTER
}

Warning: This may impact your website speed if you have many elements. 警告:如果您有很多因素,这可能会影响您的网站速度。

Also, I'd like to know what do you guys think. 另外,我想知道你们的想法。 Is there a better way to do this? 有一个更好的方法吗?

Purpose: Render a determinated content element created in typo3 and editable from there where I can call in partials by selecting their id. 目的:渲染一个在typo3中创建并可以从那里编辑的确定的内容元素,在这里我可以通过选择其id来调用局部变量。 The function must search if posible from a determinated typo3 page/folder(id) and select the desired content element through data parameters. 该函数必须从确定的typo3页面/文件夹(id)中搜索可能的内容,然后通过数据参数选择所需的内容元素。 So this way I can use an editable footer element that will repeat on every page for instance. 因此,通过这种方式,我可以使用可编辑的页脚元素,例如,它将在每个页面上重复。

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

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