使用TYPO3 be_layout,如何正确选择前端模板(性能方面)? [英] With TYPO3 be_layout, how to choose frontend template correctly (performance-wise)?

查看:13
本文介绍了使用TYPO3 be_layout,如何正确选择前端模板(性能方面)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的大多数网站中,我一直在使用以下代码来决定应将哪个模板应用于内容呈现 - 基于编辑器在 be_layout 中选择的内容:

In most of my sites, I've been using the following code to decide which template should be applied to the content rendering - based on what the editor has picked in be_layout:

page.10 = TEMPLATE
page.10 {
    stdWrap.if {
       value = 1
       isInList.data = levelfield:-1,backend_layout_next_level,slide
       isInList.override.data = TSFE:page|backend_layout
    }
    template = FILE
    template.file = fileadmin/templates/main/tmpl/main.html
    ...
}
page.20 = TEMPLATE
page.20 {
    stdWrap.if {
       value = 2
       isInList.data = levelfield:-1,backend_layout_next_level,slide
       isInList.override.data = TSFE:page|backend_layout
    }
    template = FILE
    template.file = fileadmin/templates/main/tmpl/special.html
    ...
}

这很好用.

但我曾期望 if 条件将确保根本不处理不必要的页面对象.直到我一直通过管理面板调查一些性能问题:我发现 page. 的两个(所有)子对象似乎都被渲染了 - 即使 if条件不适用.

But I had expected that the if condition would make sure that unnecessary page objects are not processed at at all. Until I've been looking into some performance issues via the admin panel: I discovered that both (all) child objects of page. seem to be rendered - even when the if condition doesn't apply.

它看起来像定期处理,然后根本不显示!所以当使用多个模板时页面渲染时间会爆炸.

It looks like it's processed regularly, and then simply not displayed! So the page rendering time explodes when using multiple templates.

我的解释正确吗?执行此操作的正确且高效的方法是什么?还是bug?

Do I interpret this correctly? What is the correct, perf-efficient way to do this? Or is it a bug?

推荐答案

CASE 对象不会像 stdWrap 中的if"条件那样行为不端".

The CASE object doesn't "misbehave" like the "if" condition in stdWrap.

这是 http://forum.typo3.org/index.php?t=tree&th=207295&goto=723619&#msg_723619:将 CASE 向上应用一级:

Here's the solution that works for me from http://forum.typo3.org/index.php?t=tree&th=207295&goto=723619&#msg_723619: apply the CASE one level upwards:

page.10 = CASE
page.10 {
    key.data = levelfield:-1,backend_layout_next_level,slide
    key.override.field = backend_layout
    default = TEMPLATE
    default {
        template = FILE
        template.file = fileadmin/templates/main/tmpl/main.html
        marks {     
                LANG < temp.language
                BASEURL < temp.baseurl
                # ... more marks
        }
    }
    # If BE Layout 1 (Standard page) - corresponds to be_layout uid
    # could be omitted, only for beauty
    1 < .default
    # If BE Layout 2 (Landingpage) - corresponds to be_layout uid
    2 < .default
    2 {
        template.file = fileadmin/templates/main/tmpl/main.html
        marks {
                MAINCONTENT < temp.teaser
                CONTENT_NAV >
                CONTENT_NAV =
        }
    }
}

当然,这也可以/应该与流体模板一起使用

Of course, this could/should also be used with a fluid template

来自使用 4 种不同 be_layouts 的站点,这里是渲染时间 - 引入 CASE 之前和之后:

From a site that uses 4 different be_layouts, here are the rendering times - before and after the introduction of the CASE:

这篇关于使用TYPO3 be_layout,如何正确选择前端模板(性能方面)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆