Create menus using data from other tables than "pages" V2

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

Here's an updated version of the PHP script, and a new example Typoscript, that tells the PHP script to look for a GET var, and use that value to determine which "page" should be set to active.

 

In the Typoscript for the userFunc, you can now set 2 extra parameters:

 

obj.header.special.userFunc.actextkey = tx_ablinklist_pi1

 

Which sets the extension key of the GET var that should be used to determine the ACT state.

And:

 

obj.header.special.userFunc.actextvar = category_uid

 

Which sets the extension variable of the GET var that should be used to determine the ACT state.

 

 


The new PHP class/function (Save it as "fileadmin/menuFunc2.inc")
-- cut --
<?php

class user_menuFunc {

function 
makeMenuArray($content,$conf) {
$menuArr = array();
$lConf $conf["userFunc."];
$actuid 0;
if (
$lConf['actextkey'] && $lConf['actextvar']) {
$getval t3lib_div::_GET();
$actuid $getval[$lConf['actextkey']][$lConf['actextvar']];
}
$res $this->cObj->exec_getQuery($lConf["table"],$lConf["select."]);
if (
$error $GLOBALS['TYPO3_DB']->sql_error()) {
$GLOBALS['TT']->setTSlogMessage($error,3);
}
else {
$GLOBALS['TT']->setTSlogMessage('NUMROWS:'.$GLOBALS['TYPO3_DB']->sql_num_rows($res));
while (
$row $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if (
$actuid!=&& $actuid==$row['uid']) $row['ITEM_STATE']='ACT';
$menuArr[] = $row;
}
}
return 
$menuArr;
}

}

?>
-- cut --

 

 

The new Typoscript Example:

 

-- cut --
page.includeLibs.menustuff = fileadmin/menuFunc2.inc

obj.header = HMENU
obj.header.special = userfunction
obj.header.special.userFunc = user_menuFunc->makeMenuArray

# Set the "table" to the DB table you want to use for the menu.
# In this example I use the Modern Linklist (ab_linklist) extension.
obj.header.special.userFunc.table = tx_ablinklist_category

# Here you set the "pidInList" to the location of your DB records.
obj.header.special.userFunc.select.pidInList = 91

# Set "actextkey" to the extension key of the GET var that
# should be used to determine the ACT state.
obj.header.special.userFunc.actextkey = tx_ablinklist_pi1

# Set "" to the extension variable of the GET var that
# should be used to determine the ACT state.
obj.header.special.userFunc.actextvar = category_uid
obj.header.1 = TMENU
obj.header.1 {
  NO {
    doNotLinkIt = 1
    stdWrap.field = label
    stdWrap.typolink.useCacheHash = 1
    stdWrap.typolink.parameter.data = page:uid
    stdWrap.typolink.additionalParams.dataWrap = &tx_ablinklist_pi1[category_uid]={field:uid}
    #stdWrap.data = debug:data
    allWrap = |<br>
  }
  ACT < .NO
  ACT = 1
  ACT.allWrap = <b>|</b><br>
}

page.7911 < obj.header
-- cut --



Comments


Peter, 24-03-08 00:27:
Small bug..

doNotLinkIt = 0

Should be:

doNotLinkIt = 1

Tobias, 24-03-08 14:04:
Thank you, changed.
Tiron, 02-10-08 17:52:
thats exactly what i needed!! great script!!
Goran, 11-03-09 14:08:
Nice, It's only way to display links on all pages as far I found on the net.
I'm wondering is it possible to have for example, top5 rated links on all pages trough:

lib.left < plugin.tx_ablinklist_pi1
lib.left.sysfolderList = 2
..
(I tried, and I also looked in the code of plugin, but it seems that this isn't possible as there is only flexform configuration for view type)

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: