[TYPO3-dev] itemArrayProcFunc inconsistent behaviour when no sub-pages - bug?
Peter
typo3 at peter-b.org
Sun Sep 23 19:19:24 CEST 2007
T3:4.1.1 on Unix/PHP5
Ok, a relatively common plugin task; produce a xMENU object that when
rendered includes links to a single page containing a plugin to render
different content based on showUid.
In the case of one particular site, this must be done using
itemArrayProcFunc, as the menu may or may not contain other items.
My problem:
If the page on which the menu is to be inserted contains no actual
sub-pages, the menu does not appear.
If I create a sub-page inside the page containing the plugin and clear
the cache, the items generated by makeMenu appear.
If I remove or hide the page without clearing the cache, the items
generated by makeMenu remain. When the cache is cleared, the items
generated by makeMenu disappear.
Whenever the items are there, everything is working as expected; the
menu is generated correctly, the links function as required. The key
problem is that if the page containing the plugin has no subpages then
the items returned by makeMenu are not rendered.
Code:
For the sake of simplicity, I've removed any TS relating to formatting:
lib.mainNav = HMENU
lib.mainNav {
special = rootline
1 = GMENU_LAYERS
1 {
expAll = 1
[..]
NO = 1
NO {
[..]
10 = TEXT
10 {
text.field = title
[..]
}
}
[..]
}
2 = GMENU_LAYERS
2 {
itemArrayProcFunc = tx_myextension_myplugin->makeMenu
[..]
NO = 1
NO {
[..]
10 = TEXT
10 {
text.field = title
[..]
}
}
[..]
}
}
function makeMenu($menuArr,$conf) {
$query = 'SELECT * FROM mytable';
$res = mysql(TYPO3_db,$query);
while ($row = mysql_fetch_assoc($res)) {
$menuArr[] = $this->pi_getRecord('pages',50);
}
}
return($menuArr);
}
}
(yes, I know the above code will generate a menu entry pointing to page
50 for each row in the table "mytable" - this is the intended behaviour
- I've stripped down the code for debugging purposes, normally the
relevant "showUid" parameter would be added).
I'm guessing this is linked to the item state of the parent menu item.
If so, is it the responsibility of the function called by
itemArrayProcFunc to control the state of that object, or should it
handle itself properly when passed items through itemArrayProcFunc even
if it has no subpages?
If it is the responsibility of the called function, how do I do it?
Peter.
More information about the TYPO3-dev
mailing list