For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > September 2004 > Strange Errors









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Strange Errors
Ricardo Cezar

2004-09-21, 4:00 pm

I´m beggining my very first Smarty website, but I´m running into strange
errors. Can you help me telling what I´m doing wrong?

The errors are as folows:
========================
Warning: Smarty::fetch(templates_c/\%%B7^B78^B78219F0%%teste.tpl.php)
[function.fetch]: failed to open stream: No such file or directory in
c:\wamp\www\anuncioscomfotos\smarty\Smar
ty.class.php on line 1248

Warning: Smarty::fetch() [function.include]: Failed opening
'templates_c/\%%B7^B78^B78219F0%%teste.tpl.php' for inclusion
(include_path='C:\wamp\php\PEAR') in
c:\wamp\www\anuncioscomfotos\smarty\Smar
ty.class.php on line 1248
========================

And here my website structure and files:

========================

C:\wamp\www\anuncioscomfotos\smarty (the libs directory)

C:\wamp\www\anuncioscomfotos\templates
C:\wamp\www\anuncioscomfotos\templates_c

C:\wamp\www\anuncioscomfotos\configs
C:\wamp\www\anuncioscomfotos\cache

C:\wamp\www\anuncioscomfotos\setup.php

C:\wamp\www\anuncioscomfotos\templates\t
este.tpl

C:\wamp\www\anuncioscomfotos\teste.php


====== setup.php ======

<?php

require("smarty/Smarty.class.php");

class MySmarty extends Smarty {

function MySmarty()
{
$this->Smarty();

$this->template_dir = "templates/";
$this->compile_dir = "templates_c/";
$this->config_dir = "configs/";
$this->cache_dir = "cache/";

$this->cacheing = true;
$this->assign("app_name", "Anúncios Com Fotos");
}
}

?>
=======================

====== teste.php ======

<?php

require('setup.php');
$smarty = new MySmarty;
$smarty->assign('name', 'Ned');
$smarty->display('teste.tpl');

?>

=======================

====== teste.tpl ======

{* Smarty *}

Hello, {$name}!

=======================
ari@riyari.com

2004-09-22, 9:10 am

Hello Ricardo Cezar,

I had the same problem when the first time I used Smarty. I think your
problem is in your php.ini that you haven't set your include_path correctly.
Please check this line :
; Windows: "\path1;\path2"

then u write below that (for example like in my WinXP Pro):
include_path=".;C:\php\pear\smarty"

I put smarty library in that folder.
But when I put my website into hosting (Linux), and they told me that they
can't change their include_path at their hosting, so I must upload smarty
library myself to my space. For security reasons, we can set .htaccess or we
can put smarty library not in folder /www
And change the name of template/template_c/config directories to our
language (just to make it strange 4 general people) or even special regional
language that we got so many in Indonesia, like Banjar for Banjarnese
(Borneo), or Bali for Balinese (Near Java), for example in hosting we can
use this :
<?
## config.inc.php
if ( ereg("config.inc.php", $PHP_SELF) ) {
header("location: index.php");
die;
}
## konfigurasi smarty
define(LIB_DIR, "/home/myusername/semelati"); // actually this is smarty
library
define(TPL_DIR, "/home/myusername/semelati_tpl"); // actually this is my
template directory
define(CPL_DIR, "/home/myusername/semelati_cpl"); // actually this is my
template_c directory

include(LIB_DIR."Smarty.class.php");
$smarty = new Smarty;
$smarty->template_dir = TPL_DIR;
$smarty->compile_dir = CPL_DIR;
?>

So when we wanna display Hello {$nama} I just use this in fileindex.php
<?
include "config.inc.php";
$smarty->assign('nama', 'Ari Keren');
$smarty->display('hello.tpl');
?>

For others, is there any other ways to secure website concerning using
Smarty ?

Best Regards,
Arie Kusuma Atmaja
www.riyari.com
Semarang - Central Java - Indonesia

> Message-ID: <20040921192207.15864.qmail@pb1.pair.com>
> To: smarty-general@lists.php.net
> From: "Ricardo Cezar" <hosptalab@wnet.com.br>
> Date: Tue, 21 Sep 2004 13:59:43 -0300
> Subject: Strange Errors
>
> I´m beggining my very first Smarty website, but I´m running into strange
> errors. Can you help me telling what I´m doing wrong?
>
> The errors are as folows:
> ========================
> Warning: Smarty::fetch(templates_c/\%%B7^B78^B78219F0%%teste.tpl.php)
> [function.fetch]: failed to open stream: No such file or directory in
> c:\wamp\www\anuncioscomfotos\smarty\Smar
ty.class.php on line 1248
>
> Warning: Smarty::fetch() [function.include]: Failed opening
> 'templates_c/\%%B7^B78^B78219F0%%teste.tpl.php' for inclusion
> (include_path='C:\wamp\php\PEAR') in
> c:\wamp\www\anuncioscomfotos\smarty\Smar
ty.class.php on line 1248
> ========================
>
> And here my website structure and files:
>
> ========================
>
> C:\wamp\www\anuncioscomfotos\smarty (the libs directory)
>
> C:\wamp\www\anuncioscomfotos\templates
> C:\wamp\www\anuncioscomfotos\templates_c

> C:\wamp\www\anuncioscomfotos\configs
> C:\wamp\www\anuncioscomfotos\cache
>
> C:\wamp\www\anuncioscomfotos\setup.php
>
> C:\wamp\www\anuncioscomfotos\templates\t
este.tpl
>
> C:\wamp\www\anuncioscomfotos\teste.php
>
>
> ====== setup.php ======
>
> <?php
>
> require("smarty/Smarty.class.php");
>
> class MySmarty extends Smarty {
>
> function MySmarty()
> {
> $this->Smarty();
>
> $this->template_dir = "templates/";
> $this->compile_dir = "templates_c/";
> $this->config_dir = "configs/";
> $this->cache_dir = "cache/";
>
> $this->cacheing = true;
> $this->assign("app_name", "Anúncios Com Fotos");
> }
> }
>
> ?>
> =======================
>
> ====== teste.php ======
>
> <?php
>
> require('setup.php');
> $smarty = new MySmarty;
> $smarty->assign('name', 'Ned');
> $smarty->display('teste.tpl');
>
> ?>
>
> =======================
>
> ====== teste.tpl ======
>
> {* Smarty *}
>
> Hello, {$name}!
>
> =======================
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com