[Typo3] Simple Menu problem?
Georg Rehfeld
georg.rehfeld at gmx.de
Sat Feb 12 16:04:53 CET 2005
Hi,
Eric Auchterberger wrote:
> This is an example, I want to unlik option2 bsubmenu option1.0 and option1.1.
> (Not care if option2 is ACTIVE or not , I just want to unlink
> selected pages on the menu. )
>
> Option0
> option0.0
> option0.1
>
> Option1
> option1.0
> option1.1
>
> Option2
> option2.0
> option2.1
I think you need an itmArrayProcFunc for this, setting the menu
state to USERDEF2 and formatting USERDEF2 differently.
Your Typoscript must look similar to this:
----------
// include our script/class, see below
includeLibs.curifsub = fileadmin/script/curifsub.inc
...
lib.menu1 {
// the menu object itself, starting off the site root
10 = HMENU
10.entryLevel = 0
...
10.1 = TMENU
10.1 {
// to hide some top level entries, but have the children
// still visible, else children would be not accessible
expAll = 1
// special processing with our script/class
itemArrayProcFunc = user_itemArrayProcFunc->markList
// here you configure the page IDs, that shall get the
// USERDEF2 state, comma separated, no spaces!!!
itemArrayProcFunc.specialUidList = 51,61
// enable config/processing for USERDEF2
USERDEF2 = 1
USERDEF2 {
// unlink these
doNotLinkIt = 1
// other formatting to your liking
...
}
// other states here ...
CUR = 1
...
}
...
}
----------
Then have the following in fileadmin/script/curifsub.inc
----------
<?php
class user_itemArrayProcFunc {
function curifsub($menuArr, $conf) {
// Enable the USERDEF1 menustate as a replacement for the
//missing CURIFSUB menustate.
// Usage: In your TMENU/GMENU object insert this line:
// itemArrayProcFunc = user_itemArrayProcFunc->curifsub
while(list($k, $v) = each($menuArr)) {
if ($conf['parentObj']->isItemState('IFSUB', $k) &&
$conf['parentObj']->isItemState('CUR', $k))
{
$menuArr[$k]['ITEM_STATE'] = 'USERDEF1';
}
}
return $menuArr;
}
/**
* A method setting the ITEM_STATE to USERDEF2, when the uid of the
* item is in a configured list. These menu items can then be
* processed differently, e.g. they might get unlinked via TS.
*
* @param array The $menuArr array which is a num-array of page
* records which go into the menu.
* @param array TypoScript configuration for the function.
* Notice that the property "parentObj" is a
* reference to the parent (calling) object (the
* tslib_Xmenu class instantiated)
* @return array The modified $menuArr array
*/
function markList($menuArr, $conf) {
$specialUids = array();
if ($conf['specialUidList']) {
$specialUids = explode(',', $conf['specialUidList']);
}
while(list($k, $v) = each($menuArr)) {
if (in_array($menuArr[$k]['uid'], $specialUids)) {
$menuArr[$k]['ITEM_STATE'] = 'USERDEF2';
}
}
return $menuArr;
}
/**
* A method setting the ITEM_STATE to USERDEF2, when the uid of the
* item is in a configured list. These menu items can then be
* processed differently, e.g. they might get unlinked via TS. Also
* adds the missing CURIFSUB state as USERDEF1, when not USERDEF2.
*
* @param array The $menuArr array which is a num-array of page
* records which go into the menu.
* @param array TypoScript configuration for the function.
* Notice that the property "parentObj" is a
* reference to the parent (calling) object (the
* tslib_Xmenu class instantiated)
* @return array The modified $menuArr array
*/
function markListAndCurifsub($menuArr, $conf) {
$specialUids = array();
if ($conf['specialUidList']) {
$specialUids = explode(',', $conf['specialUidList']);
}
while(list($k, $v) = each($menuArr)) {
if (in_array($menuArr[$k]['uid'], $specialUids)) {
$menuArr[$k]['ITEM_STATE'] = 'USERDEF2';
}
else if ($conf['parentObj']->isItemState('IFSUB', $k) &&
$conf['parentObj']->isItemState('CUR', $k))
{
$menuArr[$k]['ITEM_STATE'] = 'USERDEF1';
}
}
return $menuArr;
}
}
?>
----------
This should do what you want.
regards, Georg
--
___ ___
| + | |__ Georg Rehfeld Woltmanstr. 12 20097 Hamburg
|_|_\ |___ georg.rehfeld.nospam at gmx.de +49 (40) 23 53 27 10
More information about the TYPO3-english
mailing list