【问题标题】:Adding of Generic Markers to tt_news - Database related向 tt_news 添加通用标记 - 与数据库相关
【发布时间】:2015-03-13 13:21:00
【问题描述】:

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

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

我想做的是:

  • 从 MySQL 表中读取数据(最好从我的扩展中)
  • 将数据与 tt_news 列进行比较(列包含 VARCHAR "1,2,3,4")
  • 查找某个 UID(其中 tt_news.txy7... 包含 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

}

【问题讨论】:

    标签: mysql typo3 typoscript tt-news


    【解决方案1】:

    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) 支持数据和包装选项的地方

    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 = | )
            }
    

    【讨论】:

    • 另外,tt_news 将不会在很长时间内得到支持。也许你应该考虑扩展 tx_news 而不是 tt_news。
    • 感谢所有输入。我为输出和常规标记的使用编写了自己的扩展。但这非常有趣,并且在以后的项目中一定要记住这一点。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多