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

Submitting your vote...
Rating: 3.0 of 5. 4 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 --

 

This snippet was submitted by Peter Klein




Comments


No comments

Add comment

* - required field

*



*
*

Top 10 Updates

Nice fonts using Google font API geändert am  20-May-2010 16:36:47
TS-based Searchbox for Indexed Search  geändert am  18-May-2010 18:27:15
TYPO3 SEO geändert am  30-Apr-2010 09:44:22
Search engine friendly graphical headers in TYPO3 geändert am  30-Apr-2010 09:33:44
Creating a simple Infocenter using TYPO3 geändert am  17-Nov-2009 12:12:52
Making the Section Menu work correctly with TemplaVoila geändert am  05-May-2009 12:27:17
Show pages with type "Not in Menu" in a sitemap geändert am  05-May-2009 12:11:17
Implementation of the DHTML menu from brainjar.com  geändert am  01-Feb-2009 14:02:48
Sample DHTML menu geändert am  01-Feb-2009 13:51:25
A introduction to the CONTENT object geändert am  26-Jan-2009 13:20:39

Latest comments

20-Aug-2010 16:31:13
pritam schrieb: Hello, Can any body tell me how to add the realurl in the typo3.
Articles
17-Aug-2010 15:25:30
Graham Solomon schrieb: I have developed a nice extension for using this Google Font API with TYPO3, along with their web...
Nice Fonts using Google font API
12-Aug-2010 17:39:44
Ritesh Jaiswal schrieb: I have added the above code into page template but it is not working. It only index the page into...
Index search
Deutsch
Search: