[TYPO3] Problems with reusing functions
Falk Walter
falkwalter at gmx.de
Mon Jul 31 18:50:35 CEST 2006
Dear Sebastian,
thank you very much for your answer! I tried to do the tt_news hack already but did not come through.
Now, I have inserted an init() function and call it from the other class. With that, it works.
I think now it would have been more intelligent to extend one from another and not both from pi_base...
In case somebody is interested, the important lines are:
require_once(t3lib_extMgm::extPath('user_logframe_report').'/pi1/class.user_logframereport_pi1.php');
class user_logframe_pi1 extends tslib_pibase {
function main($content,$conf) {
// Innitiates user_logframereport_log_frame_item
$this->userLogFrameReports = t3lib_div::makeInstance('user_logframereport_pi1');
$this->userLogFrameReports->init();
...
}
...}
and in the other class simply
class user_logframereport_pi1 extends tslib_pibase {
...
function init() {
$this->cObj = t3lib_div::makeInstance('tslib_cObj');
}
...
}
Thanks though and have a nice day.
Falk
------------------------------
>
> Message: 12
> Date: Mon, 31 Jul 2006 18:42:33 +0200
> From: Sebastian Fuchs <sebastian at hexerei.net>
> Subject: Re: [TYPO3] Problems with reusing functions
> To: typo3-english at lists.netfielders.de
> Message-ID:
> <mailman.1.1154363217.17509.typo3-english at lists.netfielders.de>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> hi Falk,
> first of all, all the best with your broken leg.
> By the way, where are you located in south america (i am looking for
> some (typo3-related) conntects there)?
>
>
> Now to your problem:
>
> Falk Walter wrote:
> >
> > Did it like that in class A:
> >
> require_once(t3lib_extMgm::extPath('user_logframe_report').'/pi1/class.user_
> > logframereport_pi1.php');
> >
> > Class A extends ... {
> >
> > $this->userLogFrameReports =
> > t3lib_div::makeInstance('user_logframereport_pi1');
> >
> > ....
> > }
> hmm, i think you dont extend the class in your class A but rather make a
> new instance of the class 'user_logframereport_pi1'. but that is not
> important for your problem.
>
> >
> > I can call functions from class B, but I got the following error
> message:
> >
> > Fatal error: Call to a member function typoLink() on a non-object in
> >
> C:\Programme\typo3\htdocs\typo3wamp\typo3\sysext\cms\tslib\class.tslib_pibas
> > e.php on line 315
> >
> > (At this line, a typolink-function gets called through the cObj:
> > return $this->cObj->typoLink($str, $conf);
> > )
>
> this means that $this->cObj is not an object with a class function
> typolink().
>
> I dont understand how your classes interact and which is called by
> which, but as a workround you could create your own cObj (which is an
> object of the class tslib_cObj in tslib/class.tslib_content.php by the
> way).
>
> $this->local_cObj = t3lib_div::makeInstance('tslib_cObj'); // Local Obj.
> maybe you have to include the php class file first.
>
> after that you could use the typolink function of this newly created
> local_cObj.
>
> I first saw this "hack" in the tt_news extension, but i came also many
> times to a point where i needed it.
>
> maybe this helps,
>
> sebastian
>
>
> ------------------------------
>
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
>
> End of TYPO3-english Digest, Vol 34, Issue 140
> **********************************************
--
---------------------------------------------
"Alles wird gut!"
Falk Walter
La Casa Roja
General Silva 699
Miraflores, Lima
Peru
Tel: +51 (1) 4 47 71 75
Billiger von Deutschland nach Peru anrufen mit:
http://www.tarif4you.de/tarife/0051.html
oder doch wieder mit der Telekom:
http://www.ausland-telefonieren.de/Vorwahl/Vorwahlnummer/guenstiger_Tarif/Peru.html
(Bitte benachrichtigt mich, falls die Links nicht mehr
gültig sein sollten...)
More information about the TYPO3-english
mailing list