[TYPO3] How to create an updated menu?
Peter Klein
peter at umloud.dk
Thu Jun 14 09:54:55 CEST 2007
"Andreas Balzer" <typo3 at andreas-balzer.de> skrev i en meddelelse
news:mailman.1.1181665346.14970.typo3-english at lists.netfielders.de...
> Andreas Balzer schrieb:
>
> Hi! I got TYPO3 executing it. Well.. The loading process of a page doesn't
> finish and the server gets quite a big load. Is there any way to do this
> with less cpu usage?
>
Hi Andreas. It works fine on my TYPO3 v4.1 installations ( I tested it on 3
different installations.)
But try this improved version instead, and see if that works better.
The PHP script:
-- cut --
<?php
class user_menuFunc {
function hideHiddenSubs($menuArr ,$conf) {
$this->pObj = $conf['parentObj'];
$limit = t3lib_div::intval_positive($conf['limit']);
$limit = $limit ? $limit : 9999;
$new_menuArr = array();
foreach ($menuArr as $pageFields) {
if ($this->ishidden($pageFields['uid'])) {
$new_menuArr[] = $pageFields;
if (count($new_menuArr)==$limit) {
return $new_menuArr;
}
}
}
return $new_menuArr;
}
function ishidden($uid) {
$row['pid'] = $uid;
while ($row['pid']!=0 && $row['pid']!=$this->pObj->id) {
$res =
$GLOBALS['TYPO3_DB']->exec_SELECTquery('pid,hidden','pages','uid='.$row['pid']);
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
if ($row['hidden']) {
return false;
}
}
return true;
}
}
?>
-- cut --
The Typoscript for my testmenu object:
-- cut --
temp.newpages = COA
temp.newpages {
wrap = <div style="border: 1px solid black;"> | </div>
10 = TEXT
10.value = New Pages
10.wrap = <div> | </div>
20 = HMENU
20.special = updated
20.special.value = 52
20.special {
#mode = lastUpdated
mode = tstamp
depth = 99
maxAge = 3600*24*7*8
#limit = 5
}
20.1 = TMENU
20.1 {
wrap = <ul> | </ul>
expAll = 1
minItems = 1
maxItems = 5
itemArrayProcFunc = user_menuFunc->hideHiddenSubs
itemArrayProcFunc.limit = 5
NO {
allWrap = <li> | </li>
}
}
}
page.44 < temp.newpages
-- cut --
BTW: Setting "itemArrayProcFunc.limit = 5" makes it work similar to setting
"limit = 5" on the HMENU object.
--
Peter Klein/Umloud Untd
More information about the TYPO3-english
mailing list