Menü für eigene Tabellen
Um Menüs für eigene Tabellen (z.B. in selbst entwickelten Extensions) zu erzeugen definiert man zunächst das Typoskript für das Menü und setzt special.userFunc auf eine eigene Funktion user_productsMenu->makeMenuArray (siehe weiter unten):
#--------------------------------
# Products Menu
#--------------------------------
page.includeLibs.usermenu = typo3conf/ext/rsys_products/classes/user_productsMenu.inc
lib.user_productsMenu = HMENU
lib.user_productsMenu {
special = userfunction
special.userFunc = user_productsMenu->makeMenuArray
special.userFunc.table = tx_rsysproducts_category
special.userFunc.select.pidInList = 5
special.userFunc.language < config.sys_language_uid
special.userFunc.treeId = 1
1 = TMENU
1 = TMENU
1 {
noBlur = 1
wrap = <ul>|</ul>
linkWrap = |
NO = 1
NO.doNotLinkIt = 1
NO.wrapItemAndSub = <li class="menu">|</li>
NO.stdWrap.htmlSpecialChars = 1
NO.ATagTitle.field = subtitle // title
NO.stdWrap.typolink {
additionalParams.insertData=1
additionalParams=&categories={field:id}
}
ACT < .NO
ACT.wrapItemAndSub = <li class="menu_selected">|</li>
}
}
}
Wenn das Menü z.B. in das "normale" Menü RSYS_MENU_02 eingefügt wird, kopiert man die wraps und Parameter von diesem Menü:
lib.user_productsMenu.1 {
NO.wrapItemAndSub < page.10.marks.RSYS_MENU_02.1.NO.wrapItemAndSub
NO.stdWrap.typolink.ATagParams < page.10.marks.RSYS_MENU_02.1.NO.ATagParams
ACT.wrapItemAndSub < page.10.marks.RSYS_MENU_02.1.ACT.wrapItemAndSub
ACT.stdWrap.typolink.ATagParams < page.10.marks.RSYS_MENU_02.1.ACT.ATagParams
}
und weist dem Marker RSYS_MENU_02 das eigene Menü zu. Die 56 ist die ID der Zielseite (mit dem Plugin zur Anzeige). Die treeId ist in diesem Fall ein Parameter, der der userFunc übergeben wird (ebenso language). Die treeId wird in diesem Fall jedoch nicht ausgewertet.
page.10.marks.RSYS_MENU_02 < lib.user_productsMenu
page.10.marks.RSYS_MENU_02.special.userFunc.treeId = 0
page.10.marks.RSYS_MENU_02.1.NO.stdWrap.typolink.parameter = 56
page.10.marks.RSYS_MENU_02.1.ACT.stdWrap.typolink.parameter = 56
Die Funktion, welche das Menü letztlich erzeugt liegt ist typo3conf/ext/rsys_products/classes/user_productsMenu.inc und sieht folgendermassen aus:
/**
* Class with menu methods for the 'rsys_products' extension.
*
* @author Erwin Knoll <typo3coding@rootsystem.de>
* @package TYPO3
* @subpackage tx_rsysproducts
*/
class user_productsMenu {
/**
* Create the entries for the custom products menu
*
* @param string $content content
* @param array $conf configuration data
* @return string modified content
*/
function makeMenuArray($content,$conf) {
$menuArr = array();
$language = $conf['userFunc.']['language'];
$category = t3lib_div::GPvar('category');
$data = new tx_rsysproducts_data($conf);
$menuArr = $data->getViewResults('categories',array());
foreach ($menuArr as &$entry) {
if($entry['id'] == $category) {
$entry['ITEM_STATE']='ACT';
}
}
return $menuArr;
}
}






