View previous topic :: View next topic |
Author |
Message |
igor Smarty Rookie
Joined: 11 Jan 2005 Posts: 6
|
Posted: Tue Jan 11, 2005 4:42 pm Post subject: subdirectory problem |
|
|
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 |
|
Fas Smarty Rookie
Joined: 10 Nov 2003 Posts: 9
|
Posted: Tue Jan 11, 2005 10:24 pm Post subject: |
|
|
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 |
|
igor Smarty Rookie
Joined: 11 Jan 2005 Posts: 6
|
Posted: Wed Jan 12, 2005 10:04 am Post subject: |
|
|
I really don't understand why but it does work now!
Really strange... |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Jan 12, 2005 2:40 pm Post subject: |
|
|
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 |
|
Bajki Smarty Rookie
Joined: 11 Jul 2006 Posts: 9
|
Posted: Fri Jul 14, 2006 8:27 am Post subject: |
|
|
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 |
|
gnuffmaster Smarty Elite
Joined: 13 Jul 2006 Posts: 440 Location: Düsseldorf, Germany
|
Posted: Fri Jul 14, 2006 9:10 am Post subject: |
|
|
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 |
|
Bajki Smarty Rookie
Joined: 11 Jul 2006 Posts: 9
|
Posted: Fri Jul 14, 2006 9:15 am Post subject: |
|
|
ok it works ! thx very much !! |
|
Back to top |
|
Hielke Hoeve Smarty Elite
Joined: 06 Jan 2006 Posts: 406 Location: Netherlands
|
Posted: Fri Jul 14, 2006 10:14 am Post subject: |
|
|
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 |
|
absameen Smarty Rookie
Joined: 21 Aug 2006 Posts: 5
|
Posted: Tue Aug 22, 2006 12:03 am Post subject: |
|
|
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 |
|
absameen Smarty Rookie
Joined: 21 Aug 2006 Posts: 5
|
Posted: Tue Aug 22, 2006 12:05 am Post subject: |
|
|
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 |
|
|