[Typo3] Get Flexform data with TypoScript
Lars Houmark
lars at houmark.com
Thu Jun 23 01:06:18 CEST 2005
Hello guys,
> Is there another way. All I have found is examples and bits which
> relies on page.something or similiar like the one you just posted.
> What I need is to get this into the menu, so that I can have a page
> specific icon left to the menu item depending on the value in the
> status of the FF field.
Ok, to finish this up, I can inform you of my solution, which I find pretty
elegant and very well working for a menu. Also this solution gives you a
very flexibel way of overwriting data. You probably already know the method
but here goes:
I made a PHP function like this:
function user_iconGenerate($I,$conf) {
$itemRow = $conf['parentObj']->menuArr[$I['key']];
$flexXML = $itemRow['tx_templavoila_flex'];
$XML = t3lib_div::xml2array($flexXML);
$icon = trim($XML['data']['sDEF']['lDEF']['field_status']['vDEF']);
$I['addATagParams'] = ' class="icon'. $icon .'"';
$conf['parentObj']->I = $I;
$conf['parentObj']->setATagParts();
$I = $conf['parentObj']->I;
if ($I['parts']['ATag_begin']) $I['parts']['ATag_begin']=$I['A1'];
// Returns:
return $I;
}
Then I made my menu, pretty simple, but the trick is the IProcFunc like
below:
includeLibs.myicons = path/to/script/file.php
lib.menu_1 = HMENU
lib.menu_1.1 = TMENU
lib.menu_1.1.IProcFunc = user_iconGenerate
lib.menu_1.1 {
noBlur = 1
wrap = <ul class="menuclass"> | </ul>
NO {
wrapItemAndSub = <li> | </li>
}
ACT = 1
ACT {
wrapItemAndSub = <li> | </li>
}
}
Each item is put through the function with all the data for the element,
also the flexform data, though they are in a bit of a mess, but the
xml2array nicely solves that. The function does its works, and overwrites
or/and adds some more data to the link and returns the item.
That was easy, when you know how to do it.
Hopefully this can help some others ;)
Have a good day and thanks for your input, it helped most of the way ;)
// Lars
More information about the TYPO3-english
mailing list