Search code examples
typo3typoscripttypo3-tca

Call TYPO3 plugin from other plugin's body


I need to call typo3 plugin from other plugin's body and pass its result to template. This is pseudo-code that describes what I want to achieve doing this:

$data['###SOME_VARIABLE###'] = $someOtherPlugin->main();
$this->cObj->substituteMarkerArray($someTemplate, $data);

Is it possible?

Thanks!


Solution

  • You should use t3lib_div:makeInstance method.

    There is a working example from TYPO3's "powermail" extension.

    function getGeo() {
        // use geo ip if loaded
        if (t3lib_extMgm::isLoaded('geoip')) {
            require_once( t3lib_extMgm::extPath('geoip').'/pi1/class.tx_geoip_pi1.php');
            $this->media = t3lib_div::makeInstance('tx_geoip_pi1');
            if ($this->conf['geoip.']['file']) { // only if file for geoip is set
                $this->media->init($this->conf['geoip.']['file']); // Initialize the geoip Ext
                $this->GEOinfos = $this->media->getGeoIP($this->ipOverride ? $this->ipOverride : t3lib_div::getIndpEnv('REMOTE_ADDR')); // get all the infos of current user ip
            }
        }
    
    }