0

我有一些复杂的菜单(几乎)需要永远渲染。

我使用nc_staticfilecache,但对于编辑者和登录用户来说,能够在每次页面加载时不重新渲染这些菜单会很棒。

我已经在考虑在特殊的 doktype 上渲染菜单,使用 cron 作业获取渲染的菜单,并将其存储到数据库或文件中,然后可以在模板中使用。

另一方面,这种情况是否有现成的方法?

4

1 回答 1

1

缓存框架可以处理这个问题。有一个属性stdWrap.cache可以完全实现这个 Typoscript-Caching。惊人的!

这是一篇与我的用例(megamenus)完全不同的德语文章 http://www.typo3.net/beitraege/typo3-cache-befehl/

我在这里复制了海报的代码,稍微简化了一下并翻译了评论:

/**
 * @author Oliver Thiele
 */

lib.megaNavigation = COA
lib.megaNavigation {
    wrap = <ul class="nav navbar-nav">|</ul>

    /**
     * Doesn't need to be cached, not slow
     */
    10 = TEXT
    10.value (
        <li class="dropdown">
            <a data-toggle="dropdown" href="#">Links</a>
            <ul class="dropdown-menu">
                <li><a href="http://extern.example.com">Externer Link</a></li>
            </ul>
        </li>
    )

    /**
     * Shouldn't be cached, highlighting is needed
     */
    20 = HMENU
    20 {
        // ... Normale Menügenerierung
        special = directory
        special.value = 1

        1 = TMENU
        1 {
            NO.wrapItemAndSub = <li>|<li>
            # …
        }
    }

    /**
     * That's the slow part we want to be cached
     */
    30 = COA
    30 {
        stdWrap {
            cache {
                /**
                 * Use language as key to identify different localisations
                 */
                key = meganavigation_contact_{TSFE:sys_language_uid}
                key.insertData = 1

                // tag can be used for later clearing
                tags = main_navigation, tx_slowextension

                /**
                 * must be seen in context of page caching
                 */
                lifetime = 3600
            }
        }


        # This would be the menu - could also be nested hmenus with content etc!
        20 < plugin.tx_slowextension_pi1

        /**
         * For testing: Timestamp
         */
        30 = TEXT
        30 {
            data = date: d.m.y H:i:s
            wrap = <li>|</li>
        }

    }
}

文档位于http://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Cache/Index.html

于 2014-12-03T11:12:55.327 回答