TYPO3 - typoscript - sys_category

时间:2016-09-05 16:02:02

标签: typo3 categories typoscript sys

我正在尝试在列表视图中显示给定内容元素的sys_category的标题,这里是一个sysfile,但是我不能为每个元素获取单个cat,我是什么我做错了?我知道,这个问题之前已被问过,但还没有合适的答案。没有液体,请TS;)

lib.category = COA
lib.category {
10 = CONTENT
  10 {
    table = sys_category
    select {
      pidInList = 1
      join = sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid
      # static id works
      #where = (uid_foreign = 751) 
      # here is the mistake?
      where.data = (uid_foreign = uid)  
      selectFields = title
    }

    renderObj = TEXT
    renderObj.field = title
    renderObj.wrap = Kategorie:|

    stdWrap.ifEmpty.cObject = TEXT
    stdWrap.ifEmpty.cObject.value = no-cat
    }
  }
}

1 个答案:

答案 0 :(得分:0)

假设您在当前记录中包含cObject->数据中的所有内容,您可以像这样访问它:

lib.category = COA
lib.category {
  10 = CONTENT
  10 {
    table = sys_category
    select {
      pidInList = 1
      join = sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid
      where.data = field:uid
      where.intval = 1
      where.wrap = (uid_foreign = |)  
      selectFields = title
    }

    renderObj = TEXT
    renderObj.field = title
    renderObj.noTrimWrap = |Category: ||

    stdWrap.ifEmpty = no-cat
  }
}

我还简化并优化了类别和ifEmpty渲染的渲染。

请注意,这仅适用于获取一个内容元素的类别。