Donaldiosa Posted August 3, 2015 Share Posted August 3, 2015 (edited) Hello, I want to include my own function-file into the module of prestashop (blocktopmenu.php). But if I do that, I get an error-msg "failed to open stream: No such file or directory". But the file exist and I don't have any idea, what is wrong here. I've inserted the following code into the function named "public function hookDisplayTop($param)". This is in the file blocktopmenu.php. I tested it with from root and without from root, with the file "my_function.php" in the root-dir and in the subdir modules/blocktopmenu/: ./home/prestashoptest/my_functions.php /home/prestashoptest/my_functions.php home/prestashoptest/my_functions.php ./home/prestashoptest/modules/blocktopmenu/my_functions.php /home/prestashoptest/modules/blocktopmenu/my_functions.php home/prestashoptest/modules/blocktopmenu/my_functions.php ../../../my_functions.phpIt doesn't work :-( Could please anyone tell me, what I have to do to inculde my own function? I want to determine the count of pieces from cart at these moments. echo '<br>getcwd='.getcwd().'<br>'; echo '<br>_PS_ROOT_DIR_='._PS_ROOT_DIR_.'<br>'; echo '<br>$_SERVER["DOCUMENT_ROOT"]='.$_SERVER["DOCUMENT_ROOT"].'<br>'; include(dirname(__FILE__). '/my_functions.php'); echo '<br>__FILE__='.__FILE__.'<br>'; include($_SERVER["DOCUMENT_ROOT"] . '/my_functions.php'); $my_products = my_get_cart('shop_cart_product'); $this->smarty->assign('TestVariable', $my_products); and than, I got these: /home/prestashoptest _PS_ROOT_DIR_=/home/prestashoptest $_SERVER["DOCUMENT_ROOT"]=/home/prestashoptest Warning: include(/home/prestashoptest/modules/blocktopmenu/my_functions.php): failed to open stream: No such file or directory in /home/prestashoptest/modules/blocktopmenu/blocktopmenu.php on line 744 Warning: include(): Failed opening '/home/prestashoptest/modules/blocktopmenu/my_functions.php' for inclusion (include_path='/home/prestashoptest/tools/htmlpurifier/standalone:.:/usr/local/lib/php') in/home/prestashoptest/modules/blocktopmenu/blocktopmenu.php on line 744 __FILE__=/home/prestashoptest/modules/blocktopmenu/blocktopmenu.php Warning: include(/home/prestashoptest/my_functions.php): failed to open stream: No such file or directory in /home/prestashoptest/modules/blocktopmenu/blocktopmenu.php on line 747 Warning: include(): Failed opening '/home/prestashoptest/my_functions.php' for inclusion (include_path='/home/prestashoptest/tools/htmlpurifier/standalone:.:/usr/local/lib/php') in/home/prestashoptest/modules/blocktopmenu/blocktopmenu.php on line 747 Fatal error: Call to undefined function my_get_cart() in /home/prestashoptest/modules/blocktopmenu/blocktopmenu.php on line 748 Edited August 5, 2015 by Donaldiosa (see edit history) Link to comment Share on other sites More sharing options...
Simone Salerno Posted August 4, 2015 Share Posted August 4, 2015 I found it easy creating a utility class in the /override/classes folder and adding my functions in it. That class gets autoloaded and you have a "namespace" for all your functions. Link to comment Share on other sites More sharing options...
Donaldiosa Posted August 5, 2015 Author Share Posted August 5, 2015 Thanks, that works fine Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now