0

我正在尝试编写自定义输出来扩展 tt_news-Extension。到目前为止,我已经成功编写了:

  • 我自己的扩展(通过扩展生成器的帮助)
  • 找到了一种通过 GENERIC Markers 和 TypoScript 输出我的一些数据的方法

我想做的是:

  • 从 MySQL 表中读取数据(最好从我的扩展中读取)
  • 将数据与 tt_news 列进行比较(列包含 VARCHAR "1,2,3,4")
  • 查找某个 UID(其中 tt_news.txy7... CONTAINS uid )
  • 仅输出在列表中找到的对象。

现在我知道我最终可能应该构建一个关系数据库,包含 uid、fahrzeug.uid、tt_news.uid ,但我真的想先找到一种输出内容的方法。

我认为我有一个基本的思维错误,但我真的需要休息一下,因为我现在为此工作了近 6 个小时。

也许有人可以为我提供一些方向?

# Output via Generic Markers
temp.fahrzeuge = CONTENT
temp.fahrzeuge {
table = tx_y7fahrzeugdatenbank_domain_model_fahrzeug
wrap = <div class="tx_y7fahrzeuge_ausgabe">|</div>
select {
  selectFields = uid,name,beschreibung
# where = tt_news.tx_y7fahrzeugdatenbank_participate CONTAINS uid
}

renderObj = COA 
renderObj {
  10 = TEXT
  10.wrap = <span class="fzname">|</span>
  10.field = name

  20 = TEXT
  20.wrap = <span class="fzdesc">|</span>
  20.field = beschreibung
}
}

plugin.tt_news.genericmarkers  {

fzparticipate = COA
fzparticipate {
 10 = TEXT
10.value = <h2>Fahrzeuge</h2>
20 = CONTENT
20 < temp.fahrzeuge.renderObj
}
#currentnews = plugin.tt_news.currentUid

}

4

1 回答 1

0

1) 将整个模板添加到您的 COA 中,而不仅仅是 renderObj:

fzparticipate = COA
fzparticipate {
 10 = TEXT
 10.value = <h2>Fahrzeuge</h2>
 20 < temp.fahrzeuge
}

2)确保您为您选择的对象设置了一个pid,并且您以某种方式在选择中设置了pidInList选项。如果你不这样做,结果将是空的!:

select {
          #set your pid here
          pidInList = 35
          # selected fields
          selectFields=uid
          where = 1=1
        }

3) 您可以通过 2 种方式添加 where 子句:Where 和 Where

3.1) andWhere 有一个可以设置的 cObject

table = tx_myTable_mapping
   select {
      #Do not forget the pid!
      pidInList = {$plugin.myPlugin.pid}
      #did you know that you can use distinct here?
      selectFields=DISTINCT(name)
      #you can use a COA here as well, for more complex clauses
      andWhere.cObject = TEXT
      andWhere.cObject {
        #This 3 lines come in handy to prevent SQLInjections 
        #by fully quoting the GET/POST variable
        data = GP:myPostVariable
        #tell the system for which table it should do the quoting
        fullQuoteStr = tx_myTable_mapping
        wrap = myTablefield=|
      }
    }

3.2) where 支持 data 和 wrap 选项

table = tx_myTable_mapping
        select {
          #you can do joins as well:
          join = fe_users on tx_myTable_mapping.fe_user = fe_users.uid
          #again with the pageId
          pidInList = {$plugin.myPlugin.pid}
          selectFields=tx_myTable_mapping.name as MyLabel
          #you can set the where in a static way like you did
          #or you use the data and wrap options
          where.data = TSFE:fe_user|user|uid
          where.wrap = (fe_users.uid = | )
        }
于 2015-03-18T11:36:53.310 回答