错字3 - 内容选择:渲染dupplicats

时间:2018-03-12 10:53:14

标签: select duplicates typo3 typoscript

我尝试根据给定的类别列出所有文件记录。 所以我在列出具有正确类别和asked about it here (solved)的所有文件时遇到了问题。

现在我遇到了问题described here

简而言之: Typo3保存已经渲染的记录,并且不再渲染它以防止无限循环。但我需要提供记录。

我的Typo3版本是7.6.18。

我开始使用这个工作代码,它只显示与categoriesie uid = 1及其孩子有关系的所有文件(在我之前的问题主题中进一步描述):

lib.documentindex = CONTENT
lib.documentindex {
  wrap = <ul>|</ul>

  table = sys_category
  select {
    pidInList = 1
    recursive = 1000
    selectFields = sys_file.name, sys_file.identifier, sys_category.title
    join = sys_category_record_mm ON (sys_category_record_mm.uid_local = sys_category.uid) JOIN sys_file_metadata ON (sys_file_metadata.uid = sys_category_record_mm.uid_foreign) JOIN sys_file ON (sys_file_metadata.file = sys_file.uid)
    where = (sys_category_record_mm.tablenames = "sys_file_metadata") AND (sys_category_record_mm.fieldname = "categories") AND ((sys_category.parent = 1) OR (sys_category.uid = 1))
    orderBy = sys_category.title
  }

  renderObj = COA
  renderObj.wrap = <li>|</li>
  renderObj.10 = TEXT
  renderObj.10 {
    field = identifier
    wrap = <a href="|">
  }
  renderObj.20 = TEXT
  renderObj.20.field = name
  renderObj.30 = TEXT
  renderObj.30.value = </a>

}

但是现在,我希望在类别上显示更多分组,例如:

Name Of Cat 1
 - File 1
 - File 2
Name Of Cat 2
- File 3

为此,我推进了这样的代码:

lib.documentindex = CONTENT
lib.documentindex {
  wrap = <ul>|</ul>

  table = sys_category
  select {
    pidInList = 1
    recursive = 1000
    selectFields = sys_category.title, sys_category.uid as theuid
    join = sys_category_record_mm ON (sys_category_record_mm.uid_local = sys_category.uid) JOIN sys_file_metadata ON (sys_file_metadata.uid = sys_category_record_mm.uid_foreign) JOIN sys_file ON (sys_file_metadata.file = sys_file.uid)
    where = (sys_category_record_mm.tablenames = "sys_file_metadata") AND (sys_category_record_mm.fieldname = "categories") AND ((sys_category.parent = 1) OR (sys_category.uid = 1))
    orderBy = sys_category.title
    groupBy = sys_category.title
  }

  renderObj = COA
  renderObj.wrap = <li>|</li>
  renderObj.10 = TEXT
  renderObj.10 {
    field = title
    wrap = <h3>|</h3>
  }

  renderObj.20 = CONTENT
  renderObj.20 {

    table = sys_category
    select {
      begin = 0
      pidInList = 1
      recursive = 1000
      selectFields = sys_file.name, sys_file.identifier
      join = sys_category_record_mm ON (sys_category_record_mm.uid_local = sys_category.uid) JOIN sys_file_metadata ON (sys_file_metadata.uid = sys_category_record_mm.uid_foreign) JOIN sys_file ON (sys_file_metadata.file = sys_file.uid)
      where = (sys_category_record_mm.tablenames = "sys_file_metadata") AND (sys_category_record_mm.fieldname = "categories")
      orderBy = sys_file.name
      andWhere.cObject = TEXT
      andWhere.cObject.dataWrap = sys_category.uid='{field:theuid}'
      //andWhere.cObject.dataWrap = sys_category.uid='4'
      andWhere.cObject.insertData= 1

    }

    renderObj = COA
    renderObj.wrap = <li>|</li>
    renderObj.10 = TEXT
    renderObj.10 {
      field = identifier
      wrap = <a href="|">
    }
    renderObj.20 = TEXT
    renderObj.20.field = name
    renderObj.30 = TEXT
    renderObj.30.value = </a>

  }

}

第一个查询用于显示至少连接了1个文件的类别的标题,第二个选择用于显示已连接的文件。

现在的问题是,由于第一次选择而导致文件被保存,并且在第二次查询中被锁定而无法呈现。

我找不到仅限typoscript的解决方法,但我已经看到这个问题已知很长时间了。现在我的问题是:有人知道问题的解决方法,只有typoscript?我不想要一个分解在多个文件上的解决方案,因为我是typo3的新手,而且我已经没有对我们的typo3项目进行概述了。

修改1:

所以我改变了第二个查询的顺序,正如Bernd Wilkeπφ告诉我的那样:

renderObj.20 {

    table = sys_file
    select {
      begin = 0
      pidInList = 1
      recursive = 1000
      selectFields = sys_file.name, sys_file.identifier
      join = sys_file_metadata ON (sys_file_metadata.file = sys_file.uid) JOIN sys_category_record_mm ON (sys_file_metadata.uid = sys_category_record_mm.uid_foreign)
      where = (sys_category_record_mm.tablenames = "sys_file_metadata") AND (sys_category_record_mm.fieldname = "categories")
      orderBy = sys_file.name
      andWhere.cObject = TEXT
      andWhere.cObject.dataWrap = sys_category_record_mm.uid_local='{field:theuid}'
      andWhere.cObject.dataWrap = //sys_category_record_mm.uid_local='2' OR sys_category_record_mm.uid_local='4'
      andWhere.cObject.insertData= 1
    }

    renderObj = COA
    renderObj.wrap = <li>|</li>
    renderObj.10 = TEXT
    renderObj.10 {
      field = identifier
      wrap = <a href="|">
    }
    renderObj.20 = TEXT
    renderObj.20.field = name
    renderObj.30 = TEXT
    renderObj.30.value = </a>

  }

就我现在所知,这取代了不能渲染我需要的记录的问题,而这个问题根本不会呈现我需要的东西。

我是否替换

sys_category_record_mm.uid_local='{field:theuid}'
//andWhere.cObject.dataWrap = sys_category_record_mm.uid_local='2' OR sys_category_record_mm.uid_local='4'

//sys_category_record_mm.uid_local='{field:theuid}'
  andWhere.cObject.dataWrap = sys_category_record_mm.uid_local='2' OR sys_category_record_mm.uid_local='4'

显示了一些记录,但我又一次出现了一个奇怪的问题,即“OR”之后的条件才算重要。因此,只显示category.uid = 4的记录。如果我在代码中将其更改为2,则会显示category.uid = 2的记录。无论如何,如果它是一个bug或其他什么,我现在不在乎。因为我希望它与andWhere.cObject.dataWrap = sys_category_record_mm.uid_local='{field:theuid}'一起使用而不是。

EDIT2:

好的,我按照预期的方式工作了,但我这样做的方式很奇怪,我不想用它。

解决方案:

renderObj.20 {

    table = sys_file
    select {
      begin = 0
      pidInList = 1
      recursive = 1000
      selectFields = sys_file.name, sys_file.identifier
      join = sys_file_metadata ON (sys_file_metadata.file = sys_file.uid) JOIN sys_category_record_mm ON (sys_file_metadata.uid = sys_category_record_mm.uid_foreign)
      where = (sys_category_record_mm.tablenames = "sys_file_metadata") AND (sys_category_record_mm.fieldname = "categories")
      orderBy = sys_file.name
      andWhere.cObject = TEXT
      andWhere.cObject.dataWrap = 0 OR sys_category_record_mm.uid_local='{field:theuid}'
      //andWhere.cObject.dataWrap = sys_category_record_mm.uid_local='2' OR sys_category_record_mm.uid_local='4'
      andWhere.cObject.insertData= 1
    }

所以,我了解到:在Typo3条件下,只有OR运算符在条件之前站立才有意义。好吧,只是一个Typo3的东西?

2 个答案:

答案 0 :(得分:0)

并且不应该以字段名称开头,而是使用AND,OR或其他官方SQL语句。所以你应该替换

andWhere.cObject.dataWrap = 0 OR sys_category_record_mm.uid_local='{field:theuid}'

andWhere.cObject.dataWrap = AND sys_category_record_mm.uid_local='{field:theuid}'

也许这感觉不那么奇怪了。 ; - )

所以我们在这里采用完全编辑的解决方案:

lib.documentindex = CONTENT
lib.documentindex {
  wrap = <ul>|</ul>    
  table = sys_category
  select {
    pidInList = 1
    recursive = 1000
    selectFields = sys_category.title, sys_category.uid as theuid
    join (
          sys_category_record_mm 
          ON (sys_category_record_mm.uid_local = sys_category.uid)
    JOIN sys_file_metadata 
          ON (sys_file_metadata.uid = sys_category_record_mm.uid_foreign)
    )
    where (
      (sys_category_record_mm.tablenames = "sys_file_metadata") AND 
      (sys_category_record_mm.fieldname = "categories") AND 
      ((sys_category.parent = 1) OR (sys_category.uid = 1))
    )
    orderBy = sys_category.title
    groupBy = sys_category.title
  }

  // context = sys_category
  renderObj = COA
  renderObj {
    wrap = <li>|</li>
    10 = TEXT
    10 {
      dataWrap = <h3>{field:title}</h3>
    }

    20 = CONTENT
    20 {
      table = sys_file
      select {
        pidInList = 1
        recursive = 1000
        selectFields = sys_file.name, sys_file.identifier
        join (
               sys_file_metadata 
                 ON (sys_file_metadata.file = sys_file.uid) 
          JOIN sys_category_record_mm 
                 ON (sys_file_metadata.uid = sys_category_record_mm.uid_foreign)
        )
        where (
          (sys_category_record_mm.tablenames = "sys_file_metadata") AND
          (sys_category_record_mm.fieldname = "categories")
        )
        orderBy = sys_file.name
        andWhere.dataWrap = AND sys_category_record_mm.uid_local='{field:theuid}'
        }
      }

      // context: sys_file
      renderObj = TEXT
      renderObj {
        wrap = <li>|</li>
        field = name
        typolink.parameter.field = identifier
      }
    }
  }
}

答案 1 :(得分:-1)

好吧,它没有意义,但它已经解决了。我想知道它为什么会这样。但我可能不应该再问自己有关错字的事了。

解决方案:

  

在Typo3条件下,只有在OR运算符之前站立时才有意义   它?!

lib.documentindex = CONTENT
lib.documentindex {
  wrap = <ul>|</ul>

  table = sys_category
  select {
    pidInList = 1
    recursive = 1000
    selectFields = sys_category.title, sys_category.uid as theuid
    join (
          sys_category_record_mm 
          ON (sys_category_record_mm.uid_local = sys_category.uid)
    JOIN sys_file_metadata 
          ON (sys_file_metadata.uid = sys_category_record_mm.uid_foreign)
    )
    where (
      (sys_category_record_mm.tablenames = "sys_file_metadata") AND 
      (sys_category_record_mm.fieldname = "categories") AND 
      ((sys_category.parent = 1) OR (sys_category.uid = 1))
    )
    orderBy = sys_category.title
    groupBy = sys_category.title
  }

  // context = sys_category
  renderObj = COA
  renderObj {
    wrap = <li>|</li>
    10 = TEXT
    10 {
      field = title
      wrap = <h3>|</h3>
    }

    20 = CONTENT
    20 {
      table = sys_file
      select {
        begin = 0
        pidInList = 1
        recursive = 1000
        selectFields = sys_file.name, sys_file.identifier
        join (
               sys_file_metadata 
                 ON (sys_file_metadata.file = sys_file.uid) 
          JOIN sys_category_record_mm 
                 ON (sys_file_metadata.uid = sys_category_record_mm.uid_foreign)
        )
        where (
          (sys_category_record_mm.tablenames = "sys_file_metadata") AND
          (sys_category_record_mm.fieldname = "categories")
        )
        orderBy = sys_file.name
        andWhere.cObject = TEXT
        andWhere.cObject {
          dataWrap = 0 OR sys_category_record_mm.uid_local='{field:theuid}'
          insertData= 1
        }
      }

      // context: sys_file
      renderObj = TEXT
      renderObj {
        wrap = <li>|</li>
        field = name
        typolink.parameter.field = identifier
      }
    }
  }
}