[TYPO3] writing a hook for starttime and endtime
Tapio Markula
tapio.markula at atwebteam.com
Sun Apr 22 10:26:54 CEST 2007
Praveen Chakravadhanula
> by problem is how to include this code into the given hook. i have never
> done it before and having problems in writing to the class.
Well hook concept was also difficult for me.
Here my hook
if (is_array
($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][TM_CONTENTACCESS_EXTkey]['addMiscellaneousItems']))
{
foreach
($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][TM_CONTENTACCESS_EXTkey]['addMiscellaneousItems']
as $classRef) {
$hookObj= &t3lib_div::getUserObj($classRef); if
(method_exists($hookObj, 'addMiscellaneousItems'))
$editMenu .=
$hookObj->addMiscellaneousItems($GLOBALS['TSFE']->id,$this->enableToolbarButtons);
}
}
The most important issue is the name of the needed function,
in this case 'addMiscellaneousItems'. Typo3 should find the mentioned
function (class method). If that class method has been found, the hook
works.
How typo3 can find the class method
Do these
1. Create a new extension
2. put into ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][TM_CONTENTACCESS_EXTkey]['addMiscellaneousItems'][]='EXT:tm_contentaccess/class.tx_ux_tm_contentaccess.php:tx_ux_tm_contentaccess';
Where
2.1
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][TM_CONTENTACCESS_EXTkey]['addMiscellaneousItems']
identification for typoe
2.2 [] = new item
2.3 EXT:tm_contentaccess/class.tx_ux_tm_contentaccess.php = file, where
the hook function
2.4 EXT:tm_contentaccess/...:tx_ux_tm_contentaccess = class, where the
hook function exist
2.5 'addMiscellaneousItems' = the name of the hook function, which
should be insided the previous mentioned class file
3) Create class file - below is an example
'class.tx_ux_tm_contentaccess.php'
<?php
class tx_ux_tm_contentaccess {
function addMiscellaneousItems($foo='',$goo='') {
$content='<li><a hfer="#" onclick="return false">some link here</a></li>';
return $content;
}
}
?>
where
'$hookObj->addMiscellaneousItems' match with 'function
addMiscellaneousItems'
More information about the TYPO3-english
mailing list