0

I am trying to write a custom output to extend the tt_news-Extension. I have suceeded so far as I have successfully written:

  • My own extension (via the help of extension builder)
  • Found a method to output some of my data via GENERIC Markers and TypoScript

What I want to do is:

  • Read Data from a MySQL Table (from my extensions preferably)
  • Compare data with a tt_news Column (Column contains VARCHAR "1,2,3,4")
  • Look for a certain UID (WHERE tt_news.txy7... CONTAINS uid )
  • Only output the objects found in the list.

Now I know I should probably build a relational database in the end, containing uid, fahrzeug.uid, tt_news.uid , but I'm really trying to figure out a way to output stuff first.

I think I have a basic thinking mistake in there, but I really need to take a break, since im working nearly 6 hours on this now.

Maybe someone could provide me with some directions?

# 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

}

Marc
  • 21
  • 4

1 Answers1

0

1) add the whole template to your COA not only the renderObj:

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

2) make sure you have a pid set for the objects you are selecting and that you in some way set the pidInList option within the select. The result will be empty if you don't!:

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

3) You can add where-clauses in 2 ways: Where & andWhere

3.1) andWhere has a cObject which you can set

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 supports data and wrap options

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 = | )
        }
denvercoder
  • 113
  • 9
  • Also, tt_news will not be supported for very long. Maybe you should consider extending tx_news instead of tt_news. – denvercoder Mar 18 '15 at 11:49
  • Thx for alle the input. I wrote my own extension for the output and the use of a regular marker. But this is very interesting and definatly keep this in mind for later projects. Thx alot! – Marc Mar 18 '15 at 12:51