[TYPO3] Navigation from other table than pages - itemArrayProcFunc

christian oettinger christian.oettinger at gmx.de
Mon Jan 29 00:43:58 CET 2007


Hi all,

The situation again in short:
I have a Standard Navigation. But on one special Page I want my 
kickstarted extension listed in the Navigation (not in Content as 
usual). The links lead on the same page, but with [ShowUid] value, so 
that I go to Single view of my extension by using my Navigation instead 
of listView.
So I had to combine Listing of the table pages (Standard) and the table 
of my extension in one Menu Content Object. This was done with 
itemArrayProcFunc which can be used on only one Menu Object (in my 
example 15.2).
Thanks to Kasper for his example script for itemArrayProcFunc and Peter 
Klein who provided a script I could reuse (see beginning of this thread)

Now, as promised, working Code.
I am happy on comments or hints to possible problems or errors

greetings from munich
christian



__________________________________________________________
Standard Menu in Setup (not altered at all)

page.15 = HMENU
page.15 {
     stdWrap.wrap = <div id="menu2">|</div>
     entryLevel = 1
}
page.15.1 = TMENU
page.15.1.target = _top
page.15.1 {
    fontColor = #ffffff
    expAll = 0
    NO {
       linkWrap = <SPAN class="zweiteebene"> |</SPAN><BR>
       ATagBeforeWrap = 1
    }
  }
page.15.2 = TMENU
page.15.2 {
    fontColor = #ffffff
    expAll = 0
    NO {
       linkWrap = <SPAN class="dritteebene"> |</SPAN><BR>
       ATagBeforeWrap = 1
    }
}



__________________________________________________________
Setup on special page (page.15.2 get altered)



includeLibs.oemenuitems = fileadmin/scripts/oe_itemArrayProcFunc.php

page.15.2 = TMENU
page.15.2 {
    fontColor = #ffffff
    expAll = 0
    itemArrayProcFunc = user_itemArrayProcFuncTest
    itemArrayProcFunc.userFunc.oe_table = {$oe_menu_table}
    itemArrayProcFunc.userFunc.select.pidInList = {$pid_of_folder}
    itemArrayProcFunc.userFunc.select.orderBy = sorting
    NO {
       ATagBeforeWrap = 1
       linkWrap = <SPAN class="dritteebene"> |</SPAN><BR>
       stdWrap.data = field:name
       stdWrap.typolink.parameter.data = TSFE:id
       stdWrap.typolink.additionalParams.field= uid
       stdWrap.typolink.additionalParams.wrap= 
&tx_oecertificates_pi1[showUid]=|
      #stdWrap.data = debug:data
   }
}



#  Configuration
#
#     itemArrayProcFunc.userFunc.oe_table = {$menu_table}
#  is used to define, on which table the menu will be based. This is vital:
#  if you configure your Setup to use tis script but Do not choose a 
table, script is terminated.
#
#     itemArrayProcFunc.userFunc.select.pidInList = {$certificatesfolder}
#  starting point: points to the folder, where the records lie.
#  though not tested you should be able to combine it with 
userFunc.select.recursive
#
#     stdWrap.data = field:name
#  is used to define, which field of the above table is used to render 
the menu.
#
#     itemArrayProcFunc.userFunc.select.orderBy = sorting
#  Like this of course only possible if you use manual ordernig in your 
extension.
#  Otherwise the field sorting does not exist and it will not work.



__________________________________________________________
script:



<?php
/***************************************************************
*  Copyright notice
*
*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY at typo3.com)
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*  A copy is found in the textfile GPL.txt and important notices to the 
license
*  from the author is found in LICENSE.txt distributed with these scripts.
*
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
  * This is an example of how to manipulate menu item arrays.
  * Used in the "testsite" package
  *
  * $Id: example_itemArrayProcFunc.php 639 2005-04-13 23:12:04Z mundaun $
  * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
  * XHTML compliant
  *
  * @author	Kasper Skaarhoj <kasperYYYY at typo3.com>
  *
  * Modified by Christian Oettinger. christian.oettinger at gmx.de
  * Modifications based on the script menuFunc.inc by Peter Klein. (all 
the names!)
  * For me it runs with typo3 4.0.4 XXXXX. But please note:
  * I am not too deep into typo3 and do not know if this is as compatible as
  * it should be regarding the core and extensions! Use at your own risk!
  */



/**
  * This function reads the data of a given table with given pid (both 
set in setup, see below)
  * and manipulates $menuArr to give out a Menu Part from another table 
as 'pages'.
  * It is not a complete Content Object, but only a Menu Object, so you 
can combine "ordinary"
  * menus and the menus provided by this script (e.g. as submenus).
  *
  * @param	array		The $menuArr array which simply is a num-array of page 
records which goes into the menu.
  * @param	array		TypoScript configuration for the function. Notice that 
the property "parentObj" is a reference to the parent (calling) object 
(the tslib_Xmenu class instantiated)
  * @return	array		The modified $menuArr array
  */
function user_itemArrayProcFuncTest($menuArr,$conf)	{
	$lConf = $conf["userFunc."];

	if ($conf['demoItemStates'])	{		// Used in the example of item states
		reset($menuArr);
		$c=0;
		$teststates=explode(',','NO,ACT,IFSUB,CUR,USR,SPC,USERDEF1,USERDEF2');
		while(list($k,$v)=each($menuArr))	{
			$menuArr[$k]['ITEM_STATE']=$teststates[$c];
			$menuArr[$k]['title'].= ($teststates[$c] ? ' ['.$teststates[$c].']' : 
'');

			$c++;
		}
	} else {	// used in the fake menu item example!		
		if ($lConf['oe_table']) {		// if table is set,

			#t3lib_div::debug ($lConf);
		
			$menuArr = array(); // resetting the array
			
			$res = 
$GLOBALS['TSFE']->cObj->exec_getQuery($lConf["oe_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)) {
					$menuArr[] = $row;
				}
			}
			
		} else {													
				die ('user_itemArrayProcFuncTest: you have not set a table. This is 
vital. '.
				 	'Please use itemArrayProcFunc.userFunc.oe_table inside NO in your 
Menu object.');
		}
	}
	#t3lib_div::debug ($menuArr);
	return $menuArr;
}

?>


More information about the TYPO3-english mailing list