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

TYPO3面包屑导航中页面标题的隐藏与替换问题

TYPO3: Replace Fixed "Article" with News Title in Breadcrumbs on Detail Pages

Got it, let's fix that breadcrumb issue on your TYPO3 news detail pages. The core problem here is that default HMENU breadcrumbs don't automatically pull the news record's title—since news details are rendered via a plugin, not as standalone pages. Your initial tweak to special = rootline wasn't enough because it only handles actual page records, not dynamic content from extensions like News. Here's how to get it working:

Solution 1: Adjust HMENU with Item Processing (TYPO3Script)

Add an ITEMProcFunc override to your breadcrumb HMENU configuration to detect news detail pages and swap the fixed "Article" text with the actual news title:

30 = HMENU
30 {
    special = rootline
    special.range = 0|-1
    1 = TMENU
    1 {
        NO = 1
        NO {
            wrap = <li>|</li>
            stdWrap.field = title
            # Override for news detail pages
            stdWrap.override.cObject = COA
            stdWrap.override.cObject {
                10 = TEXT
                10 {
                    # Check if we're on a news detail page via the plugin's GET parameter
                    data = GP:tx_news_pi1|news
                    required = 1
                    # Fetch the news title from the database
                    stdWrap.cObject = CONTENT
                    stdWrap.cObject {
                        table = tx_news_domain_model_news
                        select {
                            uid.data = GP:tx_news_pi1|news
                            pidInList = 123 # Replace with your news storage page ID(s) (comma-separated for multiple)
                        }
                        renderObj = TEXT
                        renderObj.field = title
                    }
                }
            }
        }
        CUR = 1
        CUR {
            wrap = <li class="active">|</li>
            stdWrap.field = title
            # Apply the same override to the active (last) breadcrumb item
            stdWrap.override.cObject < .NO.stdWrap.override.cObject
        }
    }
}

Key Notes for This Method:

  • Replace pidInList = 123 with your actual news storage page ID(s)
  • If you're using a custom news plugin (not the default tx_news_pi1), update the GP: parameter to match your plugin's namespace (e.g., GP:tx_mycustomnews_pi1|news)
  • Clear TYPO3's cache after saving the configuration—this is critical for changes to take effect

Solution 2: Use Route Enhancers (TYPO3 v10+)

If you're on TYPO3 v10 or newer, you can leverage Route Enhancers to make the news detail page's breadcrumb automatically recognize the news title. Edit your site configuration file (config/sites/your-site/config.yaml):

routeEnhancers:
  NewsPlugin:
    type: Extbase
    limitToPages: [789] # Replace with your news list page ID
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
    defaultController: 'News::detail'
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment

How This Works:

  • This configures clean URLs for news details (e.g., /news/my-awesome-news-title instead of ?tx_news_pi1[news]=123)
  • TYPO3 will automatically map the path_segment (auto-generated or manually set in the news record) to the news title in breadcrumbs
  • Ensure all your news records have a path_segment value (the News extension usually generates this automatically when you save a news item)

Solution 3: Fluid Template Override

If your breadcrumbs are rendered via a Fluid template, you can directly check for news detail pages and swap the title there. Example snippet:

<f:for each="{breadcrumbs}" as="crumb" iteration="iterator">
  <li class="{f:if(condition: iterator.isLast, then: 'active')}">
    <f:if condition="{iterator.isLast && request.query.get('tx_news_pi1[news]')}">
      <f:then>
        <!-- Replace {newsItem.title} with your actual news object variable -->
        <span>{newsItem.title}</span>
      </f:then>
      <f:else>
        <f:link.page pageUid="{crumb.data.uid}">{crumb.data.title}</f:link.page>
      </f:else>
    </f:if>
  </li>
</f:for>

This works best if you're already passing the newsItem object to your breadcrumb partial from the news detail template.

Test out these methods—most users find the first TYPO3Script approach works seamlessly with traditional HMENU setups. Don't forget to clear the cache after making changes!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 04:02:50