|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Tyz Smarty n00b
Joined: 29 Nov 2004 Posts: 1 Location: Netherlands
|
Posted: Mon Nov 29, 2004 3:08 pm Post subject: variable in the 'include'->'file' attribute |
|
|
Hi,
This is wat i'm trying to do and will not work, so does anybody has a sollution or alternative?
I have 1 tpl file that is used for the main structure of the site, and I want to include all the element tpl's when there needed. Point is that the tpl it has to insert is dynamicly chosen.
In the main tpl I use the smarty 'include' function, my problem now is how to give the right tpl file with it.
{include file="theDynamicChosenTPL"}
Is there anyway to put a smarty variable in de file attribute?
grtz |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Nov 29, 2004 3:16 pm Post subject: |
|
|
{include file=$my_dynamic_tpl_file} |
|
Back to top |
|
disoft Smarty n00b
Joined: 09 Dec 2004 Posts: 4
|
Posted: Thu Dec 09, 2004 9:13 pm Post subject: |
|
|
Hi,
A related question to the above.
Is is possible to use a variable for part of the file name? What I'm trying to do is something like:
{include file="{$dirname}/filename.php"}
But I can't seem to get the syntax correct. Tried:
{include file=$dirname . "/filename.php"}
{include file="$dirname/filename.php"}
And a few others.
Best regards,
Gordon. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Dec 09, 2004 9:20 pm Post subject: |
|
|
{include} is for including other template files (and parsing them) from the template directory. To include arbitrary text files from the file system, use {fetch}. To include php scripts that are executed during inclusion, use {include_php}. |
|
Back to top |
|
disoft Smarty n00b
Joined: 09 Dec 2004 Posts: 4
|
Posted: Fri Dec 10, 2004 8:17 am Post subject: |
|
|
mohrt wrote: | {include} is for including other template files (and parsing them) from the template directory. To include arbitrary text files from the file system, use {fetch}. To include php scripts that are executed during inclusion, use {include_php}. |
Okay, thanks for that, but it still doesn't allow me to use a variable in the call for part of the path. I presume that can't be done. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Dec 10, 2004 2:44 pm Post subject: |
|
|
Yes, this should work:
{include file="$foo/bar.tpl"}
assuming $foo is an assigned template var and this directory exists inside of your template directory. |
|
Back to top |
|
|
|
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
|