Typo3 eID, how to access config OR fetch template from ajax file


In eID mode, only a small part of the regular TYPO3 frontend is loaded. Unfortunately TypoScript is not loaded. To still access the TypoScript configuration you need manually load the components it needs to do so. Unfortunately this can be a bit of a pain in the butt. So in some cases it might be easier to just load a page containing a single plugin that doesn’t contain anything else (without headers etc.).

If you do want to load the TypoScript templates yourself, you can try something like the following:

<?php //if (!defined (‘TYPO3_MODE’))die (‘Access denied.’);

ini_set(“display_errors”,1);

t3lib_div::requireOnce(PATH_tslib.’class.tslib_fe.php’);
t3lib_div::requireOnce(PATH_t3lib.’class.t3lib_userauth.php’ );
t3lib_div::requireOnce(PATH_tslib.’class.tslib_feuserauth.php’);
t3lib_div::requireOnce(PATH_t3lib.’class.t3lib_cs.php’);
t3lib_div::requireOnce(PATH_tslib.’class.tslib_content.php’) ;
t3lib_div::requireOnce(PATH_t3lib.’class.t3lib_tstemplate.php’);
t3lib_div::requireOnce(PATH_t3lib.’class.t3lib_page.php’);

$TSFEclassName = t3lib_div::makeInstance(‘tslib_fe’);
$id = isset($HTTP_GET_VARS[‘id’])?$HTTP_GET_VARS[‘id’]:0;

$GLOBALS[‘TSFE’] = new $TSFEclassName($TYPO3_CONF_VARS, $id, ‘0’, 1, ”,”,”,”);
$GLOBALS[‘TSFE’]->connectToMySQL();
$GLOBALS[‘TSFE’]->initFEuser();
$GLOBALS[‘TSFE’]->fetch_the_id();
$GLOBALS[‘TSFE’]->getPageAndRootline();
$GLOBALS[‘TSFE’]->initTemplate();
$GLOBALS[‘TSFE’]->tmpl->getFileName_backPath = PATH_site;
$GLOBALS[‘TSFE’]->forceTemplateParsing = 1;
$GLOBALS[‘TSFE’]->getConfigArray();

class CLASS_NAME {

  protected $uid;

  public function __construct() {
      tslib_eidtools::connectDB();
      $this->cObj = t3lib_div::makeInstance(‘tslib_cObj’);
  }

  public function main() {
      $templateFile = ‘EXT:EXTENSION_NAME/pi1/view/template.html’;
      $template = $this->cObj->fileResource($templateFile);
      $subpart = $this->cObj->getSubpart($template, ‘###TEMPLATE###’);
      $subpartArray = $linkpartArray = array();
      return $this->cObj->substituteMarkerArrayCached($subpart, $markerArray, $subpartArray, $linkpartArray);
  }

}

$obj = t3lib_div::makeInstance(‘CLASS_NAME’);

$obj->main();

// Make instance:

?>

Good Luck….. 🙂

If you have any query then feel free to contact me at Jainish Senjaliya

Advertisements

3 thoughts on “Typo3 eID, how to access config OR fetch template from ajax file

  1. Very helpful, thanks. Please note that the funtion connectToMySQL() is deprecated and not supported anymore in recent Typo3 Version. Use connectToDB() instead.

    Reply
  2. $HTTP_GET_VARS is very old-fashioned and no more supported on many PHP environments. Use $_GET or use the appropriate function provided by Typo3: t3lib_div::_GP(‘id’)

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s