View previous topic :: View next topic |
Author |
Message |
idle0ne Smarty Rookie
Joined: 16 Oct 2003 Posts: 22 Location: Vermont
|
Posted: Thu Oct 16, 2003 8:37 pm Post subject: Including Other TPL Files |
|
|
hello,
the way i have my site setup is like so
/
/smarty/
/themes/
/themes/default/
index.php
now in my themes/default/ are all my TPL files, they seem to work, however when i use an include in my header.tpl file to include navmenu.tpl which are in the same directory, it isn't called or included
here is what i am using
{include file="$theme_dir/navmenu.tpl"}
i got that from the smarty site.
Joe
Last edited by idle0ne on Thu Oct 16, 2003 8:45 pm; edited 1 time in total |
|
Back to top |
|
idle0ne Smarty Rookie
Joined: 16 Oct 2003 Posts: 22 Location: Vermont
|
Posted: Thu Oct 16, 2003 8:44 pm Post subject: |
|
|
i checked the compiled template and here is what smarty is using for the include. I am not sure if this is correct or not....
<?php
$_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include($this->_tpl_vars['theme_dir']."/navmenu.tpl", array());
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
?> |
|
Back to top |
|
idle0ne Smarty Rookie
Joined: 16 Oct 2003 Posts: 22 Location: Vermont
|
Posted: Thu Oct 16, 2003 8:48 pm Post subject: |
|
|
i have even attempted this
<!-- #include file="{$theme_dir}/navmenu.tpl" -->
and it seems smarty won't allow that type of include and just prints it as a comment to the browser |
|
Back to top |
|
idle0ne Smarty Rookie
Joined: 16 Oct 2003 Posts: 22 Location: Vermont
|
Posted: Thu Oct 16, 2003 9:47 pm Post subject: |
|
|
anyone have any ideas? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Oct 16, 2003 9:49 pm Post subject: |
|
|
Include works by starting to scan for files in your templates_dir. So to inlclude a template you simply say {include file="template.tpl"}. Now, say you want to include a template from a subdir, you type {include file="subdir/subtemplate.tpl"}.
In your example, $theme_dir must be a dir that is under templates_dir, eg: $theme_dir = "subdir".
On the otherhand, if you want to use an absolute path, then you must prefix the path with the file resource: {include file="file:/path/to/template/...."}
HTH |
|
Back to top |
|
idle0ne Smarty Rookie
Joined: 16 Oct 2003 Posts: 22 Location: Vermont
|
Posted: Thu Oct 16, 2003 10:06 pm Post subject: |
|
|
right now the way they are being called is like so
$theme_dir = themes/default/
so it is calling like this when evaluated
{include file="themes/default/navmenu.tpl"}
but for some odd reason it's not including the file |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Oct 16, 2003 10:20 pm Post subject: |
|
|
what IS Smarty doing? Do you get an error? Make sure that dbugging is turned on and that error reporting is at E_ALL.
EDIT: According to your first post, themes/ is not a subdir of your template directory. |
|
Back to top |
|
idle0ne Smarty Rookie
Joined: 16 Oct 2003 Posts: 22 Location: Vermont
|
Posted: Thu Oct 16, 2003 10:27 pm Post subject: |
|
|
is it searching /smarty/templates/
??
if so how can i change that to make it search /themes/default/ |
|
Back to top |
|
idle0ne Smarty Rookie
Joined: 16 Oct 2003 Posts: 22 Location: Vermont
|
Posted: Thu Oct 16, 2003 10:27 pm Post subject: |
|
|
wait i already have that set
$this->_smarty->template_dir = $site->_settings->theme;
$site->_settings->theme = themes/default/ |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Oct 16, 2003 10:41 pm Post subject: |
|
|
if themes/default/ is your template dir, then smarty won't find $theme_dir/template.tpl when $theme_dir = 'themes/default' UNLESS you have your template directory (themes/default/) contains a directory structure that includes "themes/default/" (ie. "themes/default/themes/default/template.tpl" must exist).
Phew. I hope that makes sense! |
|
Back to top |
|
idle0ne Smarty Rookie
Joined: 16 Oct 2003 Posts: 22 Location: Vermont
|
Posted: Thu Oct 16, 2003 10:55 pm Post subject: |
|
|
i qm confused lol here's my dir structure
base/
base/theme/
base/theme/default/
base/smarty/
and i have smarty's template var pointing to base/theme/default, do i not???
i am confused as to why it's not working hehe, do i need to specify the full path and not a reletive path? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Oct 16, 2003 10:59 pm Post subject: |
|
|
idle0ne wrote: | i qm confused lol here's my dir structure
base/
base/theme/
base/theme/default/
base/smarty/
and i have smarty's template var pointing to base/theme/default, do i not??? |
The way I read it, I think you want to point templates_dir to 'base/theme' and then do your includes using $theme_dir = 'default' (or whatever the appropriate theme is). That way it will resolve to default/template.tpl which will resolve to $templates_dir.'default/template.tpl' => base/theme/default/template.tpl
tada! |
|
Back to top |
|
idle0ne Smarty Rookie
Joined: 16 Oct 2003 Posts: 22 Location: Vermont
|
Posted: Thu Oct 16, 2003 11:06 pm Post subject: |
|
|
exactly but i can't seem to get it to work lol |
|
Back to top |
|
idle0ne Smarty Rookie
Joined: 16 Oct 2003 Posts: 22 Location: Vermont
|
Posted: Fri Oct 17, 2003 1:24 am Post subject: |
|
|
ok here is how i have it set now and it sorta works
$this->_smarty->template_dir = $this->_site->_settings->_site_root."/theme/".$this->_site->_user->_theme;
that echo's this
c://inetpub//wwwroot//tfans/theme/themes/default/
but for some odd reason when i do my include i get this
Warning: Smarty error: unable to read template resource: "navmenu.tpl" in c:\inetpub\wwwroot\tfans\smarty\Smarty.class.php on line 1042
why is it still looking in the smarty folder, if it is hehe?? |
|
Back to top |
|
idle0ne Smarty Rookie
Joined: 16 Oct 2003 Posts: 22 Location: Vermont
|
Posted: Fri Oct 17, 2003 1:29 am Post subject: |
|
|
WOOOOHOOOOO I got it to work FINALLY
thanks for all the help |
|
Back to top |
|
|