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.
Master file as default.master.php breaks vanilla.
shayr
New
Hello.
I have vanilla installed on my server and am in the process of making my own theme for my website. When I have a "default.master.tpl" file in my theme folder under views folder all is well. I want to use some php in the master file so I changed it to "default.master.php" and it broke my form. Now when I go to the website I get the "something went wrong" page with the big crossed eyed smiley.
I need to use some php code so any help will be appreciated.
I am using Vanilla 2.2 if it changes anything.
1
Comments
@shayr
Welcome to the community.
You can't just change the file suffix, although you can use default.master.php files.
Generally, you can enter php in a tpl file inside tags.
If you let us know what you are trying to achieve, it may be that there is a pre-existing solution.
Hello.
First, thanks for the super quick reply. I was trying to add some Js and CSS files to the head part. I was able to do it via theme hooks using $sender->Head->AddCss('/path/to/file') and $Sender->Head->AddScript('path/to/file') using the Base_Render_Before function. It worked, but the problem is I need the files to load at the END of the head part, while the method I used put it the beginning of the part.
In addition I will want to add some more php custom functionality to the theme master file.
As of Vanilla 2.1 , the master template is a tpl based one. You can use any php based theme , try my themes and see.
If you want to use a tpl based theme, the themehooks file is the place to put your php.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
@vrijvlinder How do I use a php based master template then? naming the file default.master.php didn't do the trick. The admin.master.php on the other hand IS a php file for some reason. I will look up your themes any case, if there's something to learn from them then thats a time spent well.
No you do not touch the default one in the applications/dashboard /views/default.master.tpl
You add a custom theme to your forum. Try one of my themes, they are mostly php based.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Never mind, just looked at your denim theme and saw the php master file. I will look at it in depth and see what you did there.
Yes, that is what I did, in accordance with the docs on the website, and then created a theme hook file for adding the css and js files, with the problem of them being added BEFORE the original ones. Also, the question remains, how can I use a default.master.php instead of a tpl file.
As I explained above, you can use anything you want as far as a custom theme. You do not mess at all with the default.master.tpl from the core files . You only deal with the custom theme.
You install the theme, that is all. I prefer php based themes so I made several.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
You do not need to do that, the files get picked up when you have them in the correct folders of a theme.
If you need to add js files or other things, it is recommended to do so via plugins.
A php based theme does not really use a themehooks file but it could. themehooks files are mostly for tpl based themes. It acts as a plugin.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Yes, thats what I did. That is, copy the tpl file into my custom theme. I just didn't know how to make it a php style master file until I looked at your Denim theme
Yes, I converted the BitterSweet theme from tpl to php based master, if you want to compare the two, download BitterSweet theme and BetterBitter which is the one I made. That way you can see what I did by comparing both themes and it's files.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Just doing it now. These themes are a big help as in the future I will need to use a php style master file. I am now comparing the tpl and php structure of the files. Thanks for the help