繁体   English   中英

Typo3 v9.5LTS部分不渲染

[英]Typo3 v9.5LTS partial not rendering

为了理解在typo3中进行模板制作的正确方法,我从typo3 6.2到typo3 v9.5,一切都是新的。 我已经实现了使用DCE的能力,创建了后端布局,现在我试图创建一个重复元素,以在具有不同模板的多个页面上使用。

与带有typo3随附的主模板的全新typo3安装相比,我可以看到它们在其中使用了一个文件

ext / your_template /资源/私人/部分/页面/结构/页脚内容

然后在模板中,他们呈现html文件,该文件从主模板加载元素(我想)。

在这里您可以看到渲染

当我尝试在自己的页面中复制此问题时,就会出现问题。 它不会在我的页面中呈现,甚至不会在html基本结构中呈现。

我在这张图片中显示的是 FooterContent.html 而在主模板中的渲染调用则如图所示

Home.html(模板)

  <f:section name="Footer">

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

  </f:section>

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>

(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
}

然后,在我的网站内部,我仅能从模板中显示内容。 换句话说,除渲染以外的所有内容都是局部的。 我看不到与此相关的任何问题,来自typo3的文档也没有对此进行澄清。 我一定想念什么,但我不知道。

编辑:添加了setup.typoscript(我正在使用从以下位置安装主题包时提供的默认设置: https ://sitepackagebuilder.com)

从注释中,解决方案应该是将该部分添加到默认页面布局文件中。

默认情况下(来自sitepackagebuilder )使用布局文件,因此必须在布局文件中定义模板中定义的部分。

在默认布局文件中,您只能找到呈现的“主”部分。

要添加Footer部分,请将RenderViewHelper放置在布局中的某个位置:

<f:render section="Footer" />

如果要使其可选,可以将属性optional="true"到ViewHelper,这样就不需要在每个模板中定义页脚节。

FLUIDTEMPLATE的结构如下所示:

  • Templates可以包含Partials ,也可以包含Sections
  • Partials可以包含其他Partials
  • Layouts包含在Templates中, Templates可以呈现Sections ,也可以包含Partials

如果要向全局页面呈现页脚,请将页脚Partial放置在Layout文件中。 如果你想有一个页脚取决于所使用的模板,将页脚的Section模板的,让呈现Section在你的Layout

只是为了澄清René的答案:

流体模板:

  • 模板 -这是进入流体的入口。 如果调用流畅,则调用模板( <f:layout name="layoutname" /> )。 模板可以确定布局; 如果这样做,则渲染从布局开始

  • 布局 -它们旨在给出总体结构。 这可以通过从确定模板和/或部分插入不同的部分来实现。

  • 局部 -这些是您页面将要构建的灵活构建块。 每当您拥有一块数据块时,它可能会更频繁地出现,或者它本身就是一个单位,请从中分离出一部分数据,以便重新使用它并构造流体。

部分可以在模板和局部中作为子块出现。
如果您插入<f:render section="sectionname" />之类的节,则该节应位于当前文件中-除布局外,他们希望其节在模板中。
如果要从另一个文件插入节,则只能从局部文件中插入节: <f:render section="sectionname" partial="partialname" /> 如果省略节名,则插入整个部分( <f:render partial="partialname" />

通常,所有带有f:render插入都不会传输任何数据(流体变量),但以下情况除外:布局会获取确定模板已知的所有数据,并且从布局插入的模板中的部分会知道初始模板的所有数据。
对于所有其他插入,您可能需要使用f:render viewhelper的arguments参数传输数据:

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

一种特殊情况:您可以使用arguments="{_all}"传输所有(本地已知的)数据

感谢RenéPflamm和Bernd Wilke的解释。 由于我来自tpyo3 v6.2,因此我在此处使用标记记录在多个模板上使用以下命令重复同一项目:

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

然后在模板中

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

这使我可以从typo3内的文件夹中获取一些匹配其ID的元素。

我不知道它是否仍然可以使用,但是我创建了一个简单的函数

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

可以在我调用typoscriptObjectPath="lib.dynamicContentFunction" ,这使我可以通过数据参数调用我要呈现的元素的ID。 这是一个示例和函数:

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

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
}

警告:如果您有很多因素,这可能会影响您的网站速度。

另外,我想知道你们的想法。 有一个更好的方法吗?

目的:渲染一个在typo3中创建并可以从那里编辑的确定的内容元素,在这里我可以通过选择其id来调用局部变量。 该函数必须从确定的typo3页面/文件夹(id)中搜索可能的内容,然后通过数据参数选择所需的内容元素。 因此,通过这种方式,我可以使用可编辑的页脚元素,例如,它将在每个页面上重复。

暂无
暂无

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

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