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
  userFunc = user_topMenu->main

user_topMenu is stand for class name
main is function name

PHP file format


  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


Leave a Reply

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

You are commenting using your 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