简体   繁体   English

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

[英]Microdata for news item in breadcrumb navigation

With the following code I build my breadcrumb navigation with the according microdata for a BreadcrumbList :使用以下代码,我使用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}|" />
        }
      }
    }
  }
}

This works perfectliy fine, but I have no idea, how to add the item <meta itemprop="position" content="{register:count_MENUOBJ}|" />这很好用,但我不知道如何添加项目<meta itemprop="position" content="{register:count_MENUOBJ}|" /> <meta itemprop="position" content="{register:count_MENUOBJ}|" /> for a newsrecord: <meta itemprop="position" content="{register:count_MENUOBJ}|" />对于新闻记录:

This is how it looks at the moment:这是它目前的样子:

// 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]

Obviously the {register:count_MENUOBJ} is not available for the news item.显然{register:count_MENUOBJ}不适用于新闻项目。

How can I get the last value of {register:count_MENUOBJ} from the menu object and increase it by one for the news item?如何从菜单 object 中获取{register:count_MENUOBJ}的最后一个值,并将新闻项目的值加一?

I had the same problem, my solution is to work with the CUR element:我遇到了同样的问题,我的解决方案是使用 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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM