php - How to include External classes for extensions in TYPO3? -


i have extension named menu requires of class menuhelper in folder ext/menu/classes/helper.

how use in controller? class 'menuhelper' being accessed when in controller folder.

i want use in controller :

public function listaction() {          $menugenerators=new menuhelper(); # return           $this->view->assign('menugenerators', $menugenerators); } 

if place class in directory yourext/classes/helper/nesteddirectory/menuhelper.php have 2 ways class in other extbase files.

first way typo3 > 6.0: using namespaces

<?php namespace yourvendor\yourextension\helper\nesteddirectory;  class menuhelper { }  ?> 

now can make instance of class using

$menuhelper = \typo3\cms\core\utility\generalutility::makeinstance("yourvendor\\yourextension\\helper\\nesteddirectory\\menuhelper") 

or using

$menuhelper = new \yourvendor\yourextension\helper\nesteddirectory\menuhelper(); 

second way typo3 <= 4.7

<?php  class tx_yourextension_helper_nesteddirectory_menuhelper { }  ?> 

now can make instance of class using

$menuhelper = t3lib_div::makeinstance("tx_yourextension_helper_nesteddirectory_menuhelper") 

or using

$menuhelper = new tx_yourextension_helper_nesteddirectory_menuhelper(); 

the name of class directs class-loader correct path of source file. important file has same name class has.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -