[TYPO3] My own tt_news display item.
Mathias R. Wulff
mathias at RaWu.dk
Mon Aug 27 11:44:21 CEST 2007
Hi.
I’m trying to make my own element in the tt_news list of what to display
(In the list of latest, single, amenu, search, catmenu.....)
I have succeeded in connecting with the hook in tt_news for this
purpose, but tt_news expects some kind of object instead of a string as
return value from my own script.
so what have I done?:
Created my own plugin in
typo3conf/ext//mrw_newscal
where
the file
typo3conf/ext//mrw_newscal/ext_tables.php
contents
<?PHP
if (TYPO3_MODE=='BE') {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['what_to_display'][] =
array('LISTBYMONTH', 'LISTBYMONTH');
}
?>
seam to work correct. The element is shown in the list.
______________
the file typo3conf/ext//mrw_newscal/ext_localconf.php
contents
<?php
if (TYPO3_MODE!='BE')
{
require_once(t3lib_extMgm::extPath('mrw_newscal').'class.mrw_newscal.php');
}
$TYPO3_CONF_VARS['EXTCONF']['tt_news']['extraCodesHook'][] = 'mrw_newscal';
?>
_____________
Finally the file
typo3conf/ext//mrw_newscal/class.mrw_newscal.php
<?php
require_once(PATH_tslib."class.tslib_pibase.php");
class mrw_newscal extends tslib_pibase{
function extraCodesProcessor($parentObject) {
$content = "";
switch($parentObject->theCode) {
case "LISTBYMONTH":
$content ="LISTBYMONTH works!";
return $content;
}
}
}
?>
Where the return statement is a string.
The output was suppose to be "LISTBYMONTH works!" but instead its an error:
Fatal error: Call to a member function on a non-object in
/typo3conf/ext/tt_news/pi/class.tx_ttnews.php on line 186
hmm. The code in
# line 182
// Adds hook for processing of extra codes
# line 183
if
(is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['extraCodesHook']))
{
# line 184
foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['extraCodesHook']
as $_classRef) {
# line 185
$_procObj = & t3lib_div::getUserObj($_classRef);
# line 186
$content .= $_procObj->extraCodesProcessor($this);
# line 187
}
# line 188
} else {
So the problem occurs in
$content .= $_procObj->extraCodesProcessor($this);
Probably because the line above
$_procObj = & t3lib_div::getUserObj($_classRef);
concatenates an existing object with the return from my
extraCodesProcessor (a string).
Does anybody know what kind of object to return?
- Mathias
More information about the TYPO3-english
mailing list