Smarty will nicht mehr

Dieses Thema im Forum "Webentwicklung" wurde erstellt von pleq, 13. Oktober 2008 .

Schlagworte:
  1. 13. Oktober 2008
    Hallo,

    mein Problem:

    Ich habe eine index.php in der wie folgt vorgegangen wird:

    PHP:
    ...
    function 
    __autoload ( $class )
      {
        require 
    'class/' . $class . '.class.php' ;
      }
    ...
    require 
    'config/functions.inc.php' ;
    require 
    'config/vars.inc.php' ;
    ...
    $tpl  = new  Smarty ();
    $tpl -> display ( DEST . "/index.tpl" );
    Die Variable DEST habe ich in der vars.inc.php definiert: DEST = "test"

    somit sollte der display Aufruf nun wie folgt lauten: $tpl->display("test/index.tpl");

    Leider bekomme ich dann folgende Fehlermeldung:

    Code:
    Warning: Smarty error: unable to read resource: "test/index.tpl" in /home/www/web116/html/v1/class/Smarty.class.php on line 1092
    Wenn ich nun in der index.php das DEST direkt durch "test" ersetze ... funktioniet es!

    Btw: auf meinem localhost funktioniert es so wie oben beschrieben!

    Weiß einer weiter?
     
  2. 13. Oktober 2008
    AW: Smarty will nicht mehr

    Haste die Pfade zu den jeweiligen Dirs angepasst?

    PHP:
    $smarty -> template_dir  '/path_to/templates/'
    $smarty -> compile_dir  '/path_to/templates_c/'
    $smarty -> config_dir  '/path_to/configs/'
    $smarty -> cache_dir  '/path_to/cache/' ;
    Hier ma gucken:
    Smarty :: View topic - Warning: Smarty error: unable to read resource: foo.tpl

    Mfg
     
  3. 13. Oktober 2008
    AW: Smarty will nicht mehr

    EDIT:

    $smarty = new Smarty();
    $smarty->template_dir = "templates";

    // use your template filename, and be sure to put the "/" in there
    // if your template_dir does not have a trailing "/"
    $myfile = $smarty->template_dir . "/test/index.tpl";
    echo "attempting to read $myfile\n";
    readfile($myfile);

    funktioniert!

    Wenn ich aber die $myfile Zeile nun so änder:

    $myfile = $smarty->template_dir . "/".DEST."/index.tpl";

    Quasi meine Konstante einsetze funktioniert es nicht mehr, warum?^^
     
  4. 13. Oktober 2008
    AW: Smarty will nicht mehr

    Soweit ich weiß nutzt Smarty intern bereits template_dir und setzt das vor jede Verzeichnis-Angabe, wenn du also später ne File aufrufen/parsen willst.
    Mach mal:
    PHP:
    $myfile  DEST . "/index.tpl" ;
    // Und später ausgeben
     
  5. 13. Oktober 2008
    AW: Smarty will nicht mehr

    hatte ich auch shcon probiert ...

    $destnew = DEST."/index.tpl";
    $tpl->display($destnew);

    gleicher fehler ...
     
  6. 13. Oktober 2008
    AW: Smarty will nicht mehr

    zwei sachen die man machen sollte wenn etwas nicht funktioniert.

    1. error-reporting einschalten und fehlermeldungen lesen+beheben
    PHP:
    error_reporting ( E_ALL | E_STRICT );
    2. probleme debuggen
    PHP:
    print  'path: "'  DEST  '"' ;
    dann siehst du direkt was in "DEST" steht (in anführungszeichen falls whitespaces drinnen sind)
     
  7. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.