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.

Can you use PHP in default.master.tpl?

edited March 2011 in Vanilla 2.0 - 2.8
I tried putting some PHP code into the default.master.tpl file of my template in an attempt to load the wordpress header.php, but it does not get parsed. When I view the source online, the PHP code is unchanged and appears to just be ignored. I also tried wrapping it in the {literal} tag to no avail. Can someone tell me if it's possible to embed PHP in this file?
«134

Comments

  • LincLinc Detroit Admin
    edited March 2011
    Are you on vanillaforums.com or your own private install? If the latter, you could just use default.master.php instead if you don't mind eschewing Smarty.
  • I'm using a private install. default.master.php it outside the theme. Will it be overriden by upgrading Vanilla? Is there any documentation explaining how these files are used?
  • LincLinc Detroit Admin
    Just copy it into your theme under your views folder and hack away. :)
  • LincLinc Detroit Admin
  • @Lincoln, is to possible to add to quick guides instructions how to use compiled Smarty templates to replace Smarty tpl with pure PHP if you need this?
  • Sounds easy enough, I'll give it a go. BTW is there a function reference API for all the Vanilla PHP calls? It would make writing new methods so much simpler.
  • edited March 2011
    @tjforsythe
    What do you mean under "function reference API"?
    Vanilla uses MVC(Model-View-Controller paradigm) and objects.
    Plus event handlers as very useful helper approach.
    Read about all this in documentation on this site.

    Plus use good IDE (I prefer PhpStorm 2.0) and look into code (it is of quite high quality, many places are commented, arguments are also described according to PHP Doc)
  • I'm new to Vanilla, but looking at the code for some of the plug-ins for instance, they are making calls to methods I expect are part of the core classes i.e. Gdn::Session(). I am wondering if there is any documentation that describes these classes and methods. I could dig through the Vanilla core and eventually figure it out, but I'd prefer to start by reviewing a manual, if there is one available, so I know what tools are already available.
  • LincLinc Detroit Admin
    Some very unofficial code documentation: http://lincolnwebs.com/vanilla2doc/ It may move.
  • LincLinc Detroit Admin
    @tjforsythe Gdn::Session() refers to an instance of the class Session, which is in library/core/class.session.php. It's not a function.
  • LincLinc Detroit Admin
    @tester13 I have never used Smarty and have no plans to learn it.
  • Great, thanks for the link to the docs. Its exactly what I've been hunting for.
  • @Lincoln

    My understanding is that you can make exactly the same documentation using Doxygen and Vanilla source?

    As for Smarty - I asked not about how to use Smarty, but on how not to use it, in, for example, Mobile theme. I heard something about taking compiled PHP versions out from the Smarty cache.
  • LincLinc Detroit Admin
    @tester13 Yeah, that's how I made it... and?

    To use PHP templates, just call your files .php instead of .tpl. PHP template files override Smarty versions afaik.
  • Where is the default.master.tpl called from so I can change the call to default.master.php?
  • You do not need to change any call, as I understand, just remove tpl and place php instead.
  • Thanks
  • LincLinc Detroit Admin
    Yeah, php always takes precedence over tpl. It's an either/or that Vanilla does automatically.
  • edited March 2011
    When I modify the default.master.php to include a header, menu and footer using lines such as <?php include('...//www.domain.com/path/include.php'); ?> (the dots as http obviously) they just seem to be thrown away. Any idea what I might be doing wrong?
  • LincLinc Detroit Admin
    edited March 2011
    Don't use includes with full paths, use echo $this->FetchView('viewname'); or include($this->FetchViewLocation('viewname'));

    If you must do a full path (i.e. the files are outside Vanilla) then you must use the relative or full system path to the file ('../../folder/file.php' or '/var/www/vhosts/folder/file.php'). You generally can't include over http.
Sign In or Register to comment.