[TYPO3-english] piBase: Render comma values to strings > TYPO3 API?

Jigal van Hemert jigal.van.hemert at typo3.org
Tue Sep 4 20:42:51 CEST 2012


Hi,

On 4-9-2012 16:28, Martin Terber wrote:
>  From the database I get "2,5,8" and I want to output the corresponding
> values (in this case categories).
> So "2,5,8" needs to be rendered as "Science, Habitation, Economy" > like
> defined in TCA.
>
> Is there an API function for this in t3lib / tslib_pibase ? Can't find
> anything.

TCA is the definition for the backend forms. For the frontend 
representation you have to arrange your own data presentation.

$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
   'title',
   'tx_myext_category',
   'uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($categoryList) . ')'
);
$categories = array();
foreach ($rows as $row) {
   $categories[] = $row['title'];
}
echo implode(', ', $categories);

-- 
Jigal van Hemert
TYPO3 Core Team member

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-english mailing list