[Typo3] Popups in menulinks
Alexander Bohndorf
bohndorf at sitegeist.de
Thu Mar 10 18:50:17 CET 2005
Hi Stefan
we created a new menu-class which inherits from tslib_tmenu and uses this in the similar way as TMENU.
In TS you only have to add one line then:
includeLibs.tmenu2 = /media/scripts/tmenu2.php
Then you have to replace TMENU with TMENU2, that's all.
Of course you have to copy the class file to /media/scripts.
To open a page in a popup-window you can use the typolink-syntax für popup-windows in the target field of the page, f.e. "800x600:menubar=0".
Here is the class file (/media/scripts/tmenu2.php):
<?php
class tslib_tmenu2 extends tslib_tmenu {
/**
* Creates the URL, target and onclick values for the menu item link. Returns them in an array as key/value pairs for <A>-tag attributes
* This function doesn't care about the url, because if we let the url be redirected, it will be logged in the stat!!!
*
* @param integer Pointer to a key in the $this->menuArr array where the value for that key represents the menu item we are linking to (page record)
* @param string Alternative target
* @param integer Alternative type
* @return array Returns an array with A-tag attributes as key/value pairs (HREF, TARGET and onClick)
* @access private
*/
function link($key,$altTarget='',$typeOverride='') {
/*
Patch von sitegeist media solutions GmbH, Alexander Bohndorf (bohndorf at sitegeist.de)
10.03.2005
Target-Notation der Form "400x300:menubar=0,status=0" umwandeln in Popup-Link
*/
// Aufruf der link-Methode der Parent-Klasse
$list = tslib_tmenu::link($key,$altTarget,$typeOverride);
// $list ist ein assoz. Array mit den Einträgen 'HREF', 'TARGET' und 'onClick'
if(ereg("^([0-9]+)x([0-9]+)(:[^:]*){0,1}",$list['TARGET'],$params))
{
(count($params)>3) ? $additionalParams = ','.substr($params[3],1) : $additionalParams = '';
$url=$list['HREF'];
$list['TARGET'] = '';
$list['onClick'] = '';
$list['HREF'] = '#';
$onClick= 'window.open(\''.$url.'\',\''.md5($url).'\',\'width='.$params[1].',height='.$params[2].$additionalParams.'\'); return false;';
}
$list['onClick'] = $onClick;
return $list;
}
}
$GLOBALS['TSFE']->tmpl->menuclasses.=',tmenu2';
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/tmenu2.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/tmenu2.php']);
}
?>
Hope that helps!
- Alexander Bohndorf (xandi)
-----------------------
This thread is located in the archive at this URL:
http://typo3.org/documentation/mailing-lists/english-main-list-archive/thread/110107962/
More information about the TYPO3-english
mailing list