[TYPO3-dev] Instantiating a cObject

Ernesto Baschny [cron IT] ernst at cron-it.de
Fri Jun 23 10:13:11 CEST 2006


Brian Slezak schrieb am 22.06.2006 22:10:

> My primary question is whether this is good form, or there is a better way
> to get at the proper TypoScript config. What I need to do is create an 
> instance of a cObject from PHP in another fe plug-in, but have its TypoScript 
> configuration passed to it.

Why do you "need" to do this? Can't you have the cObject specification
under your plugin TypoScript settings so that you have access to it in
$conf?

> I've accomplished this by this example:
> (pseudo-code, incomplete, included through a static template)
> 
> my_cObject = USER
> my_cObject {
> ....
> }
> 
> From some other fe plug-in:
> 
> require_once(PATH_typo3conf . 'ext/path/class.my_cObject .php');
> ....
> $my_class = t3lib_div::makeInstance('my_cObject );
> $content =
> $this->cObj->cObjGetSingle($GLOBALS['TSFE']->tmpl->setup['plugin.']['my_cObject'],
> $GLOBALS['TSFE']->tmpl->setup['plugin.']['my_cObject.']);
> 
> Stating the question again, is it ok to go at the TypoScript configuration
> via $GLOBALS['TSFE']->tmpl->setup['plugin.']['my_cObject'] like that, or is
> there a better way to accomplish this?

If you really need settings from one plugin in another one, this is
probably the only way to do it in PHP. But you might want to just
reference the settings you need in your own plugin object, where you
have direct access to it ($conf):

plugin.blabla = USER
...
  my_cObject =< my_cObject
...

Then just access $conf['my_cObject.'] in your FE-plugin.

Cheers,
Ernesto




More information about the TYPO3-dev mailing list