Bug #14466
closedContent returned from USER_INT cannot be manipulated by TypoScript
0%
Description
Content returned from USER_INT cannot be manipulated by TypoScript functions like "split" & "listNum"
Example:
PHP class (saved as fileadmin/templates/functions.inc)
-- cut --
class user_uml{
function getRandomRecordIds($content,$conf){
$lCObj = t3lib_div::makeInstance("tslib_cObj");
$table = $conf['table'];
$pid = $conf['pid'];
$max = $conf['max'];
$query = 'SELECT * FROM '.$table.' WHERE pid='.$pid.$lCObj->enableFields($table).' ORDER BY RAND() LIMIT 0,'.$max;
$res = mysql(TYPO3_db,$query);
$ar = array();
while($row = mysql_fetch_assoc($res)){
$ar[] = $row['uid'];
}
return implode(",",$ar);
}
}
?>
-- cut --
-- cut --
- Page ID where the records are located
lib.randomRecords.pid = 350
- Table to get the records from
lib.randomRecords.table = tt_address
- Max number of record IDs to return
lib.randomRecords.max = 4
-- cut --
SETUP:
-- cut --
lib.randomRecords2 = COA
lib.randomRecords2 {
10 = TEXT
10.cObject = USER_INT
10.cObject.userFunc = user_uml->getRandomRecordIds
10.cObject.pid = {$lib.randomRecords.pid}
10.cObject.table = {$lib.randomRecords.table}
10.cObject.max = {$lib.randomRecords.max}
10.wrap = This is the complete commaseperated list:: |<br>
20 < .10
20.listNum = 0
20.wrap = This should be the 1st item on the comma seperated list: |<br>
30 < .10
30.listNum = 1
30.wrap = And this should be the 2nd item on the comma seperated list: |<br>
}
lib.randomRecords3 = COA_INT
lib.randomRecords3 {
10 = TEXT
10.cObject = TEXT
10.cObject.preUserFunc = user_uml->getRandomRecordIds
10.cObject.preUserFunc.pid = {$lib.randomRecords.pid}
10.cObject.preUserFunc.table = {$lib.randomRecords.table}
10.cObject.preUserFunc.max = {$lib.randomRecords.max}
10.wrap = This is the complete commaseperated list:: |<br>
20 < .10
20.listNum = 0
20.wrap = This should be the 1st item on the comma seperated list: |<br>
30 < .10
30.listNum = 1
30.wrap = And this should be the 2nd item on the comma seperated list: |<br>
}
- Default PAGE object:
page = PAGE
page.typeNum = 0
page.6.value = <br><br>
page.7 < lib.randomRecords2
page.8 = TEXT
page.8.value = <br><br>
page.9 < lib.randomRecords3
-- cut --
Running the test example above, outputs something like this:
This is the complete commaseperated list:: 1,2,6,4
This should be the 1st item on the comma seperated list: 6,5,4,2
And this should be the 2nd item on the comma seperated list:
This is the complete commaseperated list:: 1,6,3,4
This should be the 1st item on the comma seperated list: 6
And this should be the 2nd item on the comma seperated list: 4
Note that the 1st part doesn't get splitted up..
(Same happens when I use the "split" function)
(issue imported from #M639)
Updated by Mathias Schreiber over 18 years ago
TYPO3 Version too old.
The reported version is no longer maintained.
If this bug still persists in 4.0.1, please re-open it again and set the field "Product Version" to the corresponding version.