Author Topic: Include Templates with variable path  (Read 1308 times)

0 Members and 1 Guest are viewing this topic.

Bombshell

  • Guest
Include Templates with variable path
on: Thu, 27. June 2002 - 11:04:00
Hello,

<TMPL_INCLUDE FILE="PATH_TO_INCLUDEFILE">

is there a possibility to set the path to the include template per variable instead of define a static path or construct some complicated if else structure?

MfG

Stefan

releasedj

  • Guest
Include Templates with variable path
Reply #1 on: Thu, 27. June 2002 - 13:24:00
No there isn't at the moment.

I will consider whether it's a viable option a little bit longer, and if it is, then I'll implement it shortly.
Can you give me some examples of how you wanted to use this?

Regards,

Kelvin

Anton

  • Guest
Include Templates with variable path
Reply #2 on: Tue, 13. May 2003 - 12:23:36
Can I write something like <TMPL_INCLUDE FILE="<TMPL_VAR NAME='PATH_TO_INCLUDEFILE'>">  ?
In this case I'll set path to template in PHP (setVar).
Sometimes I know which template will be included in realtime only. Consider, for example, multilingual site with separate templates for languages. Depending on user's preferences in language I'll set path.

By the way, may included file containts vLibTemplate's tags also?

releasedj

  • Guest
Include Templates with variable path
Reply #3 on: Tue, 13. May 2003 - 14:01:22
Currently you can not. However you can use an if statement to include the correct statement, i.e.:

Code: [Select]
<tmpl_if name="lang_en">
    <tmpl_include file="template/english/page.html">
<tmpl_elseif name="lang_fr" />
    <tmpl_include file="template/french/page.html">
<tmpl_elseif name="lang_de" />
    <tmpl_include file="template/german/page.html">
</tmpl_if>

Regards,
Kelvin
Last Edit: Sun, 28. January 2007 - 22:21:06 by ClausVB

Anton

  • Guest
Include Templates with variable path
Reply #4 on: Tue, 13. May 2003 - 14:43:02
Thank you very much for your advice!
Multiple thmpl_if is not very beautiful way, but this is a possible way.

Regarding last question in my previous reply:
Consider your code.

Can included templates, e.g.

english/page.html
french/page.html
german/page.html

have Vlib tags like tmpl_var, tmpl_if etc or can not?
And if they can, must I create separate objects for them (in additional to creating object for "parent" template)?

releasedj

  • Guest
Include Templates with variable path
Reply #5 on: Tue, 13. May 2003 - 15:44:24
1.Yes you can use tags.
2. No you do not have to create a seperate object.

I know this is a bit messy, however if you want to put this kind of logic in a template, I'm afraid this is the only way.

Alternatively, you can create different vlibTemplate objects for each template, and just display each one in the order you wish. This would probably make your templates easier to manage.

Regards,

Kelvin