[Typo3-dev] cObj Error when using hook

Martin Kutschker Martin.Kutschker at n0spam-blackbox.net
Thu Dec 22 13:39:18 CET 2005


Thomas Mammitzsch schrieb:
> Martin Kutschker schrieb:
> 
>>
>>Ahem, the call references $this. Anyway, AFAIR, all hook functiosn have
>>a reference in $params['pObj'], so you can access the properties of the
>>"parent" object.
>>
>>Masi
> 
> using $this->pObj->cObj instead of $this->cObj worked out, thanks! But i
> still don't understand why $this->cObj doesn't exist in my extension. As
> far as i've seen most other extensions use $this->cObj without
> instanciating it.

Most (if not all) plugins are derived from tslib_base AND are 
instantiated as USER or USER_INT objects during the page rendering. In 
this case they start live with a reference to the "default" cObject in 
$this->cObj. This is done by the rendering code outside of the plugins 
main() function.

OTOH if you're implementing a hook with a class of your own the class 
jsut get's instantiated and your method will be called. In this case 
there are no predifined "mgical" properties of your class. So 
$this->cObj has no more meaning than $this->myStuff unless you define 
those properties.

Masi




More information about the TYPO3-dev mailing list