You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TYPO3 EXT:news不同templateLayouts对应独立TypoScript配置咨询

嘿,这个需求其实用EXT:news自带的配置能力就能轻松搞定,我给你推荐两种实用的实现方式,按需选择就行:

方案1:通过TypoScript条件精准匹配配置

这是最直接的方式——利用TypoScript的条件判断,根据插件flexform里选中的templateLayout(也就是你说的list-type 98/99)来单独设置每页显示条数:

# 先设置默认值,比如给list-type 99用
plugin.tx_news.settings.list.paginate.itemsPerPage = 10

# 当选中的是list-type 98时,覆盖为5条
[data:flexform_templateLayout = 98]
    plugin.tx_news.settings.list.paginate.itemsPerPage = 5
[global]

注意事项:

  • 确保你在flexform配置里的templateLayout选项值确实是98和99(比如flexform里用<numindex index="98">这类定义),这样data:flexform_templateLayout才能正确读取到对应的值。
  • 这个写法在TYPO3 v10及以上版本都能正常工作,老版本条件语法略有不同,但核心逻辑一致。
方案2:在Flexform中绑定配置(更灵活的扩展方案)

如果以后你想让不同的templateLayout对应可自定义的条数,还可以直接在flexform里给每个类型关联独立的分页配置项:

  1. 先在插件flexform里添加分页条数的输入字段:
<field name="settings.list.paginate.itemsPerPage">
    <label>Items per page</label>
    <config>
        <type>input</type>
        <size>3</size>
        <eval>int</eval>
        <default>10</default>
    </config>
</field>
  1. 然后在TypoScript里开启flexform对该配置的覆盖:
plugin.tx_news.settings >
plugin.tx_news.settings < plugin.tx_news.settings.overrideFlexformSettingsIfEmpty
plugin.tx_news.settings.list.paginate.itemsPerPage = TEXT
plugin.tx_news.settings.list.paginate.itemsPerPage {
    data = flexform:settings.list.paginate.itemsPerPage
    override = 10 # 默认值
}

这样你就能在插件编辑界面,针对选中的98/99分别设置5和10,后续调整也不用改TypoScript,直接在后台操作就行。

内容的提问来源于stack exchange,提问作者Mario Wilhelm

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 03:44:57