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

如何在Site Sets设置中访问扩展的常量(选项)

如何在Site Sets中访问扩展常量并配置News扩展

核心逻辑

Site Sets(站点配置)的常量可以覆盖扩展默认配置,通过指定对应扩展的常量路径,就能实现当前站点的个性化配置。以News扩展为例,操作步骤如下:

步骤1:在站点配置中添加News扩展的常量

有两种配置方式可选:

方式一:通过TYPO3后台站点管理界面操作

  1. 进入TYPO3后台,点击左侧菜单栏「Site Management」
  2. 选中目标站点,切换到「Constants」标签页
  3. 在编辑框中写入News扩展的配置常量,示例:
plugin.tx_news {
  settings {
    storagePid = 123  # 替换为你的新闻存储页面ID
    limit = 5         # 首页新闻列表展示条数
    orderBy = datetime
    orderDirection = desc
  }
}
  1. 保存配置即可。

方式二:直接编辑站点配置文件

找到站点配置文件(路径通常为config/sites/[站点标识]/config.yaml),添加constants节点:

constants:
  plugin.tx_news.settings.storagePid: '123'
  plugin.tx_news.settings.limit: '5'
  plugin.tx_news.settings.orderBy: 'datetime'
  plugin.tx_news.settings.orderDirection: 'desc'

保存文件后,TYPO3会自动加载新配置。

步骤2:确保TypoScript读取站点常量

在模板的TypoScript中,需要将站点配置的常量传递给News插件,保证配置生效:

# 直接继承站点配置的所有News常量
plugin.tx_news.settings < plugin.tx_news.settings

# 也可单独指定生效的配置项(可选)
plugin.tx_news.settings.storagePid = {$plugin.tx_news.settings.storagePid}
plugin.tx_news.settings.limit = {$plugin.tx_news.settings.limit}

验证配置效果

刷新前端页面,检查新闻列表是否按设置的条数、排序规则展示,且仅加载指定存储页面的新闻,以此确认配置生效。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 15:04:55