I am trying to add a reference to a tt_news entry by using the following typoscript code:
plugin.tt_news.genericmarkers {
data = tx_extendednews_referenz
REFERENZ = CONTENT
REFERENZ {
table = tx_referenzen
select {
pidInList = 8
selectFields = tx_referenzen.title
andWhere.dataWrap = tx_referenzen.uid = {field:generic_tx_extendednews_referenz}
}
renderObj = COA
renderObj {
10 = TEXT
10.field = title
}
}
}
The ###GENERIC_REFERENZ###
marker shows the title of the corresponding reference, so it seems like it works. but there is this typo3 error message in the header of the page saying I have an error in my SQL syntax. The lastBuiltQuery looks like this:
SELECT tx_referenzen.title, tx_referenzen.uid as uid, tx_referenzen.pid as pid FROM tx_referenzen WHERE tx_referenzen.pid IN (8) AND tx_referenzen.uid = AND tx_referenzen.deleted=0 AND tx_referenzen.hidden=0
So there is the corresponding reference uid missing in the query, that came with the andWhere
in the typoscript code. i am wondering, why it is missing in the query, though on the page the correct reference title shows up.
When I just reload (strg+r) the page, the error message disappears, but when I press strg+shift+r, it comes back. What is wrong with the typoscript? Any ideas?
update:
I changed the select-statement to:
select {
pidInList = 8
selectFields = tx_referenzen.title, tx_referenzen.uid
andWhere {
dataWrap = tx_referenzen.uid = {field:generic_tx_extendednews_referenz}
if.isTrue.data = field:generic_tx_extendednews_referenz
if.isTrue.data.ifEmpty = 1
}
}
Now it seems to work in the first place. The error message is gone and it shows the corresponding reference with the news entry. but: Now if there is no reference added to the news-entry, all of the references are listed next to the news entry instead of none. So I have to change my question to: how do I change the typoscript so that it only lists references if there are any added to a news entry?
This would be my solution:
data = tx_extendednews_referenz
1 = LOAD_REGISTER
1.param.cObject = TEXT
1.param.cObject.value = 0
1.param.cObject.override.data = field:generic_tx_extendednews_referenz
REFERENZ = CONTENT
REFERENZ {
table = tx_referenzen
select {
pidInList = 8
selectFields = tx_referenzen.title, tx_referenzen.images, tx_referenzen.uid
andWhere = tx_referenzen.uid = {REGISTER:param}
andWhere.insertData = 1
}
it defines a default value of 0 in the register and if your field is not empty this default value is overwritten by the field-value.