Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

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}!

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

Report this thread to moderator Post Follow-up to this message
Old Post
Ricardo Cezar
09-21-04 09:00 PM


Re: Strange Errors
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}!
>
> =======================
>

Report this thread to moderator Post Follow-up to this message
Old Post
ari@riyari.com
09-22-04 02:10 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Smarty Templates archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:17 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.