Smarty, Pfad-Problem

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Smarty, Pfad-Problem

    Hi,

    ich versuche mich gerade mit Smarty. Installieren (lokal) war kein Problem. Nun wollte ich mir eine Klasse schreiben, die mir einfach die Pfade setzt und das Smarty-Objekt anlegt. So ist es auch in einer Installationsanleitung beschrieben.

    Leider erscheint bei mir folgender Fehler:

    Quellcode

    1. Warning: Smarty error: unable to read resource: "test.tpl" in C:\phpDev\smarty\libs\Smarty.class.php on line 1095


    meine ordnerstruktur kurz:
    C:\phpDev\smarty\libs
    C:\phpDev\smarty\template_c
    C:\phpDev\smarty\cache
    C:\phpDev\htdocs\smarty\templates
    C:\phpDev\htdocs\smarty\config

    meine Klasse (C:\phpDev\htdocs\smarty\loadSmarty.php):

    Quellcode

    1. <?php
    2. // load Smarty library
    3. require('Smarty.class.php');
    4. class loadSmarty extends Smarty
    5. {
    6. function loadSmarty()
    7. {
    8. // Class Constructor.
    9. // These automatically get set with each new instance.
    10. $this->Smarty();
    11. $this->template_dir = ' C:/phpDev/htdocs/smarty/templates';
    12. $this->config_dir = ' C:/phpDev/htdocs/smarty/config';
    13. $this->compile_dir = 'C:/phpDev/smarty/templates_c';
    14. $this->cache_dir = 'C:/phpDev/smarty/cache';
    15. $this->assign('app_name', 'standard');
    16. }
    17. }
    18. ?>
    Alles anzeigen


    und meine test.php (liegt in C:\phpDev\htdocs\ordner)

    Quellcode

    1. <?php
    2. require('../smarty/loadSmarty.php');
    3. $smarty = new loadSmarty;
    4. $smarty->assign('name','Ned');
    5. $smarty->display('test.tpl');
    6. ?>


    Ich finde grad den Fehler nicht, suche schon ne Stunde und irgendwann wird man einfach "blind". Wäre nett, wenn mir jemand helfen könnt.
    Danke im Voraus

    cya
  • Hi ihr beiden,

    das was d0nUt empfohlen hat, hat nichts gebracht und natürlich existierte die Datei test.tpl dort.

    Ich habe den Fehler gefunden und kann ihn irgendwie nicht glauben *grübel*

    Das Problem war, dass ein Slash am Ende des Pfades gefehlt hatte, was komisch ist, denn das hatte ich vor ein paar Stunden schon probiert.

    also die Lösung lautet wie folgt:

    Quellcode

    1. <?php
    2. // load Smarty library
    3. require('Smarty.class.php');
    4. class loadSmarty extends Smarty
    5. {
    6. function loadSmarty()
    7. {
    8. // Class Constructor.
    9. // These automatically get set with each new instance.
    10. $this->Smarty();
    11. $this->template_dir = 'C:/phpDev/htdocs/smarty/templates/';
    12. $this->config_dir = 'C:/phpDev/htdocs/smarty/config/';
    13. $this->compile_dir = 'C:/phpDev/smarty/templates_c/';
    14. $this->cache_dir = 'C:/phpDev/smarty/cache/';
    15. $this->assign('app_name', 'standard');
    16. }
    17. }
    18. ?>
    Alles anzeigen


    na mal sehen, wie weit ich noch komme, bis das nächste ähnliche Problem auftritt. ;)

    Danke auf jeden Fall für euer Engagement.

    cya