How to include custom PHP file in typo3.


Below script will use for include php file in all pages.


includeLibs.cookie = fileadmin/cookie/cookie.php

page.20 = USER_INT
page.20 {
  userFunc = user_setcookie
}

PHP file use only for particular object than we have to replace page.20 to our custom object.

includeLibs.topMenu = fileadmin/topMenu/topMenu.php

lib.mainMenu = USER
lib.mainMenu{
  userFunc = user_topMenu->main
}

Note: 
user_topMenu is stand for class name
main is function name

PHP file format

<?php

  class user_topMenu
  { 
    var $cObj;    // reference to the calling object.     

    function main($content,$conf) 
    {

      global $TYPO3_DB;

      $this->fullURL  = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
      $cObject  = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_cObj');
      $lan  = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('L');

      ......
      ......
    }
  }
?>

I hope it will work for you 🙂

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Advertisements

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