Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Smarty Templates Location

Very simple question, I hope.

I would like to use Smarty include file='....' in a theme I am using.
After looking through a compiled template it appears that this is not something disabled.
I haven't been able to figure out where to put the template file I'd like to include. Most obvious places, theme view folder does not appear to work nor it does inclusion using the file system absolute path or relative to site doc root.

I would appreciate is someone knows where template files can be placed.
I know that this can be set in the Smarty class itself but I was unable to find the location in the version of Smarty used by Vanilla.



  • Options

    view/default.master.tpl that is the only smarty file.

    grep is your friend.

  • Options

    I know that.
    I'd like to put an include file line into view/default.master.tpl so that I have
    {include file='myfile.tpl'}

    I need this flexibility to make changes depending on some condition (yes I am using Vanilla for something it was not designed to do but it's working well, mostly, as always).

    Question I was asking is - where do I put myfile.tpl so that it is read. Few obvious locations I tried do not work.

  • Options

    Sorry this feature is disabled. It is not possible to do it like this directly.

    You have the option of creating theme hooks.

    You can create a module (in php) that can be loaded in you template file.

    Another possibility it to create a function an load it as a smarty function then you can use it in your template. You could even get it to load a template file.

    You can also file custom event, which you then hook in you themehoook file, and do whatever with.

    grep is your friend.

  • Options

    Thanks for the answer.
    Too bad. Include is a simple solution for some situations.
    I know I can create a module or create a function. Both seem an overkill for my need.

    There are other ways too.

    Thanks again.

  • Options
    x00x00 MVP
    edited July 2013

    we have given you about 4-5 different ways to do it.

    I think the event way is quite good, although kasperisager's way is equally valid.

    I think it is better to use the template to yield rather that having includes directly in the template.

    grep is your friend.

  • Options

    Thanks a lot.

    This is an excellent idea.
    I very much appreciate all replies. This is a great community.

  • Options

    way to go, kasper on the cutting edge!

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    Hehe, working at the Montreal office has its benefits :)

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

Sign In or Register to comment.