'TYPO3 sys_catecory

I am using TYPO3 10 and the news extension. My news page is separatet into four tabs that uses the category as tab name. I try to output the category, e.g. tab name if is current selected and want to output as title in the title-tag by using typoscript, how can I do that?

This is my current TypoScript:

[page["uid"] == 6]

lib.categoryTitle = CONTENT
lib.categoryTitle {
    if.isTrue.data = GP:tx_news_pi1|news
    table = tx_news_domain_model_news
    select {
        uidInList.data = GP:tx_news_pi1|news
        pidInList = 57
        join = sys_category_record_mm ON tx_news_domain_model_news.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
        orderBy = sys_category.sorting
        max = 1
    }
    renderObj = TEXT
    renderObj {
        field = title
        htmlSpecialChars = 1
    }
}

page = PAGE
page {
  headerData {
    10 = TEXT
    10 {
      field = title
      noTrimWrap = |<title>News zu: | </title>|
    }
  }
}

page.headerData.10 =
page.headerData.10 < lib.categoryTitle

[END]



Solution 1:[1]

You are overriding the type of page.headerData.10 while copying: page.headerData.10 < lib.categoryTitle. So it's a CONTENT-cobject now, which does not have stdWrap-data type. So the noTrimWrap is not taken into account anymore.

But it has a stdWrap-property: move the wrap to page.headerData.10.stdWrap.noTrimWrap. Then, there will be a title-tag again, and the browser won't default to the URL.


Update 2022-03-17:

With the copy of lib.categoryTitle applied and the above modification, it should evaluate as TypoScript:

page = PAGE
page {
  headerData {
    10 = CONTENT
    10 {
      field = title
      stdWrap.noTrimWrap = |<title>News zu: | </title>|
      
      if.isTrue.data = GP:tx_news_pi1|news
      table = tx_news_domain_model_news
      select {
        uidInList.data = GP:tx_news_pi1|news
        pidInList = 57
        join = sys_category_record_mm ON tx_news_domain_model_news.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
        orderBy = sys_category.sorting
        max = 1
      }

      renderObj = TEXT
      renderObj {
        field = title
        htmlSpecialChars = 1
      }
    }
  }
}

field is no property of CONTENT, so it should be ignored and output can't be "News zu: 'Pagetitle'"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1