[TYPO3-dev] TCA - type select, select from joined tables?

Steffen Ritter info at rs-websystems.de
Tue May 20 12:18:10 CEST 2008


Well,
you can provide your own function building the select field. But then 
you won't get a display of the selected value in the backend on list view.
if you use foreign_table there are some more configuration options (not 
well documented except then in sourcecode)
THe function t3lib_befunc::exec_foreign_table_where_query will handle 
your request.
it evaluates
'foreign_table_where' => ...
while setting
###REC_FIELD_
###CURRENT_PID###, ###THIS_UID###, ###THIS_CID### ,###STORAGE_PID###, 
###SITEROOT###, ###PAGE_TSCONFIG_ID, ###PAGE_TSCONFIG_IDLIST###, 
###PAGE_TSCONFIG_STR###
After replacing this markers the "WhereString" is parsed by 
$GLOBALS['TYPO3_DB']->splitGroupOrderLimit($fTWHERE)

So I just did not try, but looking at source I think it should be 
possible usning
foreign_table => table1, table2, table3, table4

foreing_table_where => table1.primKey = table2.foreignKey AND 		
	table2.primKey =  table3.ForeignKey AND table3.primKey = 	
	table4.ForeignKey AND table4.primKey = 134 AND table3.field2 = 1
	AND table2.field3 = 1;


But since there is no handling for what label there should be used you 
will have to play a trick...
the fields which should bee fetched get reduced only to uid, since there 
is no TCA Definition for a table called "table1, table2, table3, table4"...
so you might set it :P
$TCA['table1, table2, table3, table4']['ctrl']['label']='table1.title';
with
$TCA['table1, table2, table3, table4']['ctrl']['label_userFunc']

you can set how the title of your items should be rendered  (details at 
t3lib_befunc:getRecordTitle)

I hope this can help you a bit

Greetings

Steffen



Brian Bendtsen schrieb:
> Hi
> I have never figured this out, how do I join tables in the TCA. I would 
> like to have a select box where it is possible to select from values in 
> a recordset thats created from joining a few tables.
> 
> My sql looks something like this:
> 
> SELECT table1.name FROM table1, table2, table3, table4 WHERE 
> table1.primKey = table2.foreignKey AND table2.primKey = 
> table3.ForeignKey AND table3.primKey = table4.ForeignKey AND 
> table4.primKey = 134 AND table3.field2 = 1 AND table2.field3 = 1;
> 
> Any help is appreciated
> 
> In the api manual, in the advanced lookup section a "itemsProcFunc" is 
> mentioned, but its not explained much.
> 
> Is there some more docs about this somewhere? Or some examples?
> 
> /Brian




More information about the TYPO3-dev mailing list