Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

subdirectory problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
igor
Smarty Rookie


Joined: 11 Jan 2005
Posts: 6

PostPosted: Tue Jan 11, 2005 4:42 pm    Post subject: subdirectory problem Reply with quote

hi,

I don't know how to setup a subdir with my templates
Code:
$smarty->display('index.tpl');

is ok but when I try to create a subdir like that

Code:
$smarty->display('/about_us/index.tpl');

it doesn't work anymore. I tried without / -> "about_us/index.tpl" without success. How do you do to avoid too much tpl files in the same directory?

Of course, I created the subdir /templates/about_us/index.tpl

Quote:
Warning: Smarty error: unable to read resource: "/about_us/index.tpl" in d:\php\www\Smarty\libs\Smarty.class.php on line 1088
Back to top
View user's profile Send private message
Fas
Smarty Rookie


Joined: 10 Nov 2003
Posts: 9

PostPosted: Tue Jan 11, 2005 10:24 pm    Post subject: Reply with quote

Don't use a forward slash at the start, I do this all the time and it works for me fine.

Example:

$smarty->display('about_us/index.tpl');
Back to top
View user's profile Send private message
igor
Smarty Rookie


Joined: 11 Jan 2005
Posts: 6

PostPosted: Wed Jan 12, 2005 10:04 am    Post subject: Reply with quote

I really don't understand why but it does work now!
Really strange...
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Jan 12, 2005 2:40 pm    Post subject: Reply with quote

Without the forward slash, Smarty looks for the template relative to the template directory. With the forward slash, it looks for the template from the root of your file system.
Back to top
View user's profile Send private message Visit poster's website
Bajki
Smarty Rookie


Joined: 11 Jul 2006
Posts: 9

PostPosted: Fri Jul 14, 2006 8:27 am    Post subject: Reply with quote

Hi
I have index.php file in /admin/ directory.
[php:1:97a4351f59]<?php
error_reporting( E_ALL );
ini_set( 'display_errors', 1 );

require '../libs/Smarty.class.php';
$table = array();
$template = new Smarty;
$template->compile_check = true;
$template->debugging = true;
$template->compile_dir = '../templates_c/admin';

mysql_connect ('localhost', 'root', 'krasnal') or die('Nie udalo polaczys sie z baza');
mysql_select_db('zin') or die('Nie udalo sie wybrac bazy');

$template->display('admin/index.tpl');

?>[/php:1:97a4351f59]

And it doesnt works :
Quote:
Warning: Smarty error: unable to read resource: "admin/index.tpl" in c:\usr\krasnal\www\zin\libs\Smarty.class.php on line 1095


offcourse files admin/index.tpl and dir ../templates_c/admin/ exist :/ What's wrong ?
Back to top
View user's profile Send private message
gnuffmaster
Smarty Elite


Joined: 13 Jul 2006
Posts: 440
Location: Düsseldorf, Germany

PostPosted: Fri Jul 14, 2006 9:10 am    Post subject: Reply with quote

Bajki wrote:
Hi
I have index.php file in /admin/ directory.
[php:1:e6c042ee06]<?php
error_reporting( E_ALL );
ini_set( 'display_errors', 1 );

require '../libs/Smarty.class.php';
$table = array();
$template = new Smarty;
$template->compile_check = true;
$template->debugging = true;
$template->compile_dir = '../templates_c/admin';

mysql_connect ('localhost', 'root', 'krasnal') or die('Nie udalo polaczys sie z baza');
mysql_select_db('zin') or die('Nie udalo sie wybrac bazy');

$template->display('admin/index.tpl');

?>[/php:1:e6c042ee06]

And it doesnt works :
Quote:
Warning: Smarty error: unable to read resource: "admin/index.tpl" in c:\usr\krasnal\www\zin\libs\Smarty.class.php on line 1095


offcourse files admin/index.tpl and dir ../templates_c/admin/ exist :/ What's wrong ?


I do it always this way for example:

[php:1:e6c042ee06]$smarty =& new Smarty();
$smarty->template_dir = "templates/";
$smarty->compile_dir = "templates_c/";
$smarty->cache_dir = "cache/";
$smarty->config_dir = "configs/";[/php:1:e6c042ee06]

As you can see i define a template dir.
So when i want to display a template like:

[php:1:e6c042ee06]$smarty->display("index.tpl");[/php:1:e6c042ee06]

Smarty knows where to find this template. In the dir "templates/index.tpl".
Back to top
View user's profile Send private message Visit poster's website
Bajki
Smarty Rookie


Joined: 11 Jul 2006
Posts: 9

PostPosted: Fri Jul 14, 2006 9:15 am    Post subject: Reply with quote

ok it works ! thx very much !!
Back to top
View user's profile Send private message
Hielke Hoeve
Smarty Elite


Joined: 06 Jan 2006
Posts: 406
Location: Netherlands

PostPosted: Fri Jul 14, 2006 10:14 am    Post subject: Reply with quote

By setting this:
Code:
$template->compile_dir = '../templates_c/admin';

All you compiled templates will end up there, even the ones that should be one dir higher (in ../templates_c/). Unless you set this variable in every php file differently.
_________________
Debug XHTML Compliance
SmartyPaginate
Smarty License Questions
---
(About Unix) The learning curve is full of aha! moments, such as that glorious day that the full beauty of grep and, later, find is revealed in all its majesty. --- Robert Uhl <ruhl@4dv.net>
Back to top
View user's profile Send private message
absameen
Smarty Rookie


Joined: 21 Aug 2006
Posts: 5

PostPosted: Tue Aug 22, 2006 12:03 am    Post subject: Reply with quote

I can't seem to get this to work.

Because I want to be able to change the template at any time, I've stored the template's path in the variable $cfg_theme.

Code:
$cfg_theme = "ladyblue";

$smarty = new Smarty;
$smarty->template_dir    = "templates/".$cfg_theme."/";


It won't work.

Code:
Smarty error: unable to read resource: "ladyblue/index.tpl"


What have I done wrong?
Back to top
View user's profile Send private message
absameen
Smarty Rookie


Joined: 21 Aug 2006
Posts: 5

PostPosted: Tue Aug 22, 2006 12:05 am    Post subject: Reply with quote

Oops, silly me. I just figured out what was wrong.

It was a stupid typo! The folder was named layblue and I called it ladyblue :S

Whoops.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP