面包屑导航中新闻项的微数据

Microdata for news item in breadcrumb navigation

使用以下代码,我使用 BreadcrumbList:

的相应微数据构建面包屑导航
lib.breadcrumb = COA
lib.breadcrumb {
  wrap = <ol class="list-inline" role="menubar" itemscope itemtype="http://schema.org/BreadcrumbList">|</ol>

  10 = HMENU
  10 {
    special = rootline
    special.range = 0|-1

    1 = TMENU
    1 {
      wrap = |

      NO {
        allWrap = <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">|</li>
        stdWrap.htmlSpecialChars = 1
        linkWrap = |
        doNotLinkIt = 0 |*||*| 1
        ATagBeforeWrap = 1
        ATagTitle.field = nav_title // title
        ATagParams = role="menuitem" itemprop="item"
        stdWrap.wrap = <span itemprop="name">|</span>

        after.cObject = COA
        after.cObject {
          5 = TEXT
          5.dataWrap = <meta itemprop="position" content="{register:count_MENUOBJ}|" />
        }
      }
    }
  }
}

这很好用,但我不知道如何为新闻记录添加项目 <meta itemprop="position" content="{register:count_MENUOBJ}|" />

这是目前的样子:

// add news title to breadcrumb if needed
[globalVar = GP:tx_news_pi1|news > 0]
  lib.breadcrumb.10.1.NO.doNotLinkIt = 0

  lib.breadcrumb.20 = COA
  lib.breadcrumb.20 {
    wrap = <li class="article" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">|</li>
    after.cObject = COA
    after.cObject {
      5 = TEXT
      5.dataWrap = <meta itemprop="position" content="{register:count_MENUOBJ}|" />
    }

    10 = RECORDS
    10 {
      dontCheckPid = 1
      tables = tx_news_domain_model_news
      source.data = GP:tx_news_pi1|news
      source.intval = 1
      conf.tx_news_domain_model_news = TEXT
      conf.tx_news_domain_model_news.field = title
      conf.tx_news_domain_model_news.htmlSpecialChars = 1
      wrap = <span itemprop="name">|</span>
    }
  }
[end]

显然 {register:count_MENUOBJ} 不适用于新闻项目。

如何从菜单对象中获取 {register:count_MENUOBJ} 的最后一个值并为新闻项目将其增加一?

我遇到了同样的问题,我的解决方案是使用 CUR 元素:

lib.breadcrumb = COA
lib.breadcrumb {
  stdWrap.wrap = <ol class="list list--inline" itemscope itemtype="http://schema.org/BreadcrumbList">|</ol>
  10 = HMENU
  10{
    special = rootline
    special.range = 0|-1
    includeNotInMenu = 1

    1 = TMENU
    1{
      noBlur = 1
      expAll = 1
   NO = 1
      NO.wrapItemAndSub = <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">|</li>
      NO.stdWrap.htmlSpecialChars = 1
      NO.stdWrap.htmlSpecialChars.preserveEntities = 1
      #NO.doNotLinkIt = |*| 0 |*| 1
   NO {
    ATagParams = itemprop="item"
    stdWrap.wrap = <span itemprop="name">|</span>
    after = <meta itemprop="position" content="{register:count_MENUOBJ}" />
    after.insertData = 1
   }

    }
  }
}

[(request.getQueryParams()['tx_news_pi1'])['news'] > 0]
 lib.breadcrumb {
  10 {
   1 {
    CUR < .NO
    CUR {
     doNotLinkIt = 1
     stdWrap2 {
        typolink {
           # Detail page
           ATagParams = itemprop="item"
           parameter.field = uid
           additionalParams.data = GP:tx_news_pi1|news
           # If there is a plugin with mode "Detail", the controller and action parameter might be skipped
           additionalParams.wrap = &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]=|
           useCacheHash = 1
           stdWrap = <span itemprop="name">|</span>
        }
      }
     stdWrap.cObject = RECORDS
     stdWrap.cObject {
      if.isTrue.data = GP:tx_news_pi1|news
      dontCheckPid = 1
      tables = tx_news_domain_model_news
      source.data = GP:tx_news_pi1|news
      source.intval = 1
      conf.tx_news_domain_model_news = TEXT
      conf.tx_news_domain_model_news {
       field = title
      }
     }
    }
   }
  }
 }
[global]