2

我想读出页面的系统类别以进一步与 tx_news 一起使用(显示与页面具有相同类别的新闻 - 因为 tx_news 正在使用系统类别)。

我正在寻找一个本机解决方案,希望通过 getText,类似于: plugin.tx_news.settings.categories.data = page:categories 但这似乎还不存在

另外,我尝试使用 sys_category_records_mm 来简化查询,其中包含该案例所需的所有信息,但 TYPO3 抱怨“$TCA 数组中没有条目”:

lib.categoryUid = CONTENT
lib.categoryUid {
  wrap = kategorien:|
  table = sys_category_record_mm
  select {
    selectFields = uid
    where = uid_foreign = {TSFE:id}
    where.insertData = 1
  }
  renderObj = TEXT
  renderObj {
    field = uid
    wrap = |,
  }
}

所以这很好,但这是不允许的。

4

3 回答 3

2

这是一个适用于我的设置的解决方案。编辑器为页面选择类别,并获取属于该类别的所有新闻项目。

temp.categoryUid = CONTENT
temp.categoryUid {
  table = pages
  select {
    // dontCheckPid doesn't exist for CONTENT objects, so make it recursive from root page (or pidInList.data = leveluid:-2
    pidInList = {$pidRoot}
    recursive = 99
    selectFields = sys_category.uid as catUid
    join = sys_category_record_mm ON pages.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
    where = sys_category_record_mm.tablenames = 'pages' AND sys_category_record_mm.uid_foreign = {TSFE:id}
    where.insertData = 1
    // not necessary for this use case
    // orderBy = sys_category.sorting
  }
  renderObj = TEXT
  renderObj {
    field = catUid
    // Hack: if there are no cats selected for a page, all news are displayed
    // so I just pass a catUid that's quite unlikely
    wrap = 999999,|,
  }
}


lib.newstest = USER
lib.newstest {
      userFunc = tx_extbase_core_bootstrap->run
      extensionName = News
      pluginName = Pi1
      switchableControllerActions {
            News {
              1 = list
            }
      }
      settings < plugin.tx_news.settings
      settings {
            limit = 5
            orderBy = datetime
            orderDirection = desc
            detailPid = {$pidNachrichtenDetail}
            overrideFlexformSettingsIfEmpty := addToList(detailPid)
            startingpoint = {$pidNachrichtenRecords}
            // for use in my fluid template
            // pluginTitle = {$llAktuell}
            // latest = 0
            // recordType = aktuell
            // https://forge.typo3.org/issues/52978
            useStdWrap = categories
            categories.override.cObject < temp.categoryUid
            categoryConjunction = or
      }

      view =< plugin.tx_news.view
}

我还不清楚recursive = 1选择中是否没有挫折。实际上,我根本不想检查当前页面的父 uid,但WHERE pages.pid IN ({current pid})总是自动插入。因此recursive = 1.

于 2015-02-17T10:19:57.453 回答
1

我找到了这个示例(德语)并对其进行了修改以显示类别 UID。

以下 TypoScript 将显示当前页面的所有类别的 UID,以逗号分隔。

10 = CONTENT
10 {
  table = pages
  select {
    uidInList.field = uid
    pidInList = 1 # UID or list of UIDs, where your categories are saved 
    selectFields = sys_category.uid as catUid
    join = sys_category_record_mm ON pages.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
    where = sys_category_record_mm.tablenames = 'pages' AND sys_category_record_mm.uid_foreign = {field:uid}
    where.insertData = 1
    orderBy = sys_category.sorting
  }
  renderObj = TEXT
  renderObj {
    field = catUid
    wrap = |,
  }
  # HACK
  # If category is empty, the mechanism below won't work
  # As long as I don't know how to query if this is empty or not,
  # just add an imaginary extra category!
  wrap = 12345,|
}

不幸的是,您必须pidInList手动设置存储类别的 UID 列表。

于 2015-02-15T13:05:53.260 回答
0

寻找页面的 cat-id:我是这样做的:

lib.cat = CONTENT
lib.cat {
  wrap = |
  table = sys_category
  select {
     pidInList = 1
     selectFields  = sys_category.uid, sys_category.title
     max = 1
     join = sys_category_record_mm ON(sys_category_record_mm.uid_local = sys_category.uid)
     where = sys_category_record_mm.tablenames='pages'
     andWhere.dataWrap = sys_category_record_mm.uid_foreign = {TSFE:id}
  }
  renderObj = COA
  renderObj {
     10 = TEXT
     10 {
        field = uid
        wrap = class="category|
     }
     20 = TEXT
     20 {
        field = title
        case = lower
        stdWrap.noTrimWrap = | |"|
     }
  }
}
于 2016-08-23T16:40:20.117 回答