Jump to content

[GELÖST] Eigene my_function.php wird per include nicht gefunden


Donaldiosa

Recommended Posts

Moin, Moin Forum!

 

Ich versuche eine eigene my_functions.php per include in der Datei blockmenu.php einzubinden, doch irgendetwas mache ich da falsch, denn ich bekomme immer nur "No such file or directory in..." angezeigt, obwohl die Datei ja existiert. Ich zweifel schon an mir selbst, bin ich denn zu blöd?

 

Wie muss man die Position des include korrekt angeben, damit er die Datei dann auch findet?

 

Bisherige Versuche my_functions.php in Verzeichnis:

  • prestashoptest/
  • prestashoptest/modules/blocktopmenu/

Aufruf des include-Versuche:

  • ./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.php

 

Eigentlich müsste die Datei doch wenigstens zu finden sein, wenn ich direkt von der Server-Root ausgehe?!

 

ich habe in der Funktion "public function hookDisplayTop($param)" in blocktopmenu.php folgendes hinzugefügt:

 

error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 1);
 
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);
 
Ausgabe ist dann:
/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 by Donaldiosa (see edit history)
Link to comment
Share on other sites

Hallo Donaldiosa,

 

wenn sich my_functions.php im gleichen Ordner wie blocktopmenu.php befindet :

include(dirname(__FILE__).'/my_functions.php');

Gerade nochmal getestet - funktioniert.

 

Um dir die echos zu ersparen wäre es vielleicht sinvoll die debug-console einzuschalten. ;)

 

Grüsse

Whiley

Link to comment
Share on other sites

Hallo Whiley,

 

vielen Dank, jetzt funktioniert es auch (endlich). Was notwendig ist, war also "dirname(__FILE__).".

 

Was ich aber immer noch nicht verstehe, warum wird die Datei nicht gefunden, wenn man direkt von root ausgeht? Hast Du da auch eine Erklärung für?

 

Wenn Du mit der Debug-Console die Einstellungen in der "defines.inc.php" meinst, das hatte ich probiert, es blieb aber bei der leeren weißen Seite und bevor ich dann dort lange überlege und suche, warum denn nun der Derbug-Modus an dieser Stelle nicht funktioniert, schalte ich da lieber direkt mal kurz an ;-)

Link to comment
Share on other sites

 

Wenn Du mit der Debug-Console die Einstellungen in der "defines.inc.php" meinst,

 

Nö, ich meine die smarty-debug-console, in der tpl (z.b. der header.tpl)

 

{debug}

 

der Browser muss natürlich pop-ups zulassen!

 

Grüsse

Whiley

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...