UserFunc to fix problems with HMENU type "special=updated"

Submitting your vote...
Rating: 1.0 of 5. 1 vote(s).
Click the rating bar to rate this item.

The HMENU type "special = updated" works fine, except that it shows pages that are subpages of hidden pages.

 

e.g.

- A --> visible

- B --> hidden

-- B.1 --> visible

-C --> visible

-- C.1 --> visible

 

So show B.1 is shown, even if B is hidden. The solution is a small userFunc. :)

 

Setting "itemArrayProcFunc.limit = 5" makes it work similar to setting "limit = 5" on the HMENU object.

 

NOTE: Changing the line:

 


if ($row['hidden']) {

 

Into:

 


if ($row['hidden'] || $row['nav_hide'] || $row['doktype']==5) {

 

This will also skip the menuitem if the "Hide in menu" checkbox is selected, or if the page type is "Not in menu"

 

The PHP script: (Save this as "fileadmin/menuFunc.inc")

 


-- 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']!=&& $row['pid']!=$this->pObj->id) {
$res $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','pages','uid='.$row['pid']);
$row $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
if (
$row['hidden']) {
return 
true;
}
}
return 
false;
}
}

?>
-- cut --

 

 

The Typoscript for my testmenu object:

-- cut --

 

page.includeLibs.newpages = fileadmin/menuFunc.inc

lib.newpages = COA
lib.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 < lib.newpages
-- cut -- - ERROR: Line 34: Object Name String, "--" was not preceded by any operator, =<>({;Line 71: Object Name String, "--" was not preceded by any operator, =<>({

 

This snippet was submitted by Peter Klein


Top 10 Updates

Using lightbox without extension geändert am  13-Jun-2008 14:20:51
Custom field for GMENU alt text geändert am  13-Jun-2008 13:58:07
Extending typoscript properties with stdWrap geändert am  13-Jun-2008 13:54:32
Create menus using data from other tables than "pages" V2  geändert am  24-Mar-2008 13:02:09
Login geändert am  17-Mar-2008 12:47:52
Forum geändert am  17-Mar-2008 10:07:47
Who is Typo3wizard.com geändert am  26-Dec-2007 16:07:32
Menu as un-nested lists (iphone navigation) geändert am  29-Oct-2007 15:05:53
IF Conditions with AND and OR operators geändert am  16-Oct-2007 19:16:04
UserFunc to fix problems with HMENU type "special=updated"  geändert am  16-Oct-2007 18:58:40
Deutsch
Search: