TYPO3: Current content ID in TypoScript

When using TypoScript to generate HTML i.e. in an FCE, you sometimes need a unique ID for that content element - everytime the FCE is used on the page.

For example, when creating an image gallery, Shadowbox requires a different ID in the rel attribute for every single gallery. Hard-coding the ID would prevent the FCE to be used multiple times on the page:

foo 1
foo 2

bar 1
bar 2
]]>

Your own FCE could get now an "ID" parameter the editor has to fill out if he wants to use the FCE multiple times. The better variant is to automatically use a different ID each time the FCE is rendered.

Now the uid of the tt_content table sounds like the ideal unique string to use here, but accessing it in TypoScript is a bit tricky.

TSFE:currentRecord unfortunately contains the current page ID only, but TemplaVoila comes to rescue here: TSFE:register|tx_templavoila_pi1.parentRec.uid. Using that in TypoScript, i.e. to wrap an image, is easy:

Written by Christian Weiske.

Comments? Please send an e-mail.