HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Template Cache Issues

I was trying to adjust a few pieces of the layout on my default template, but the changes were not showing up. So, I cleared most of the files in my /cache folder and even looked at the following troubleshooting article (https://docs.vanillaforums.com/developer/troubleshooting/). However, even when I revert the default template back to the default (out-of-the-box) template, nothing in my layout changes. I can adjust other views, but not my default template. I've cleared my browser cache, restarted the browser, changed themes (and changed them back), but nothing seems to work. Any other ideas?

Comments

  • Update: I was updating the smarty_function_breadcrumbs function and apparently that was the cause of the caching issue. It wasn't updating my /cache/Smarty files which were causing issues. It's working as expected now. I guess that's just something you can't do?

  • R_JR_J Admin

    Yes it can be done and I guess you had some code error, but it shouldn't be done like that. There is no need to change any file that comes with Vanilla and it is a bad idea to do so.

    Let's assume you want to have a theme called "Fancy".

    1. Create a custom theme by making a copy of a theme you like to /themes/fancy
    2. Change fancy/about.php and/or fancy/addon.json
    3. Copy the smarty function to themes/fancy/SmartyPlugins/function.fancybreadcrumbs.php
    4. Change the copy the way you like
    5. Create a file class.fancythemehooks.php:
    <?php
    
    class FancyThemeHooks implements Gdn_IPlugin {
        public function setup() {
            return true;
        }
        public function onDisable() {
            return true;
        }
    
        public function gdn_smarty_init_handler($sender) {
            $sender->addPluginsDir(__DIR__.'/SmartyPlugins');
        }
    }
    

    Just to be safe, delete /cache/theme-index.php and if it exists also /cache/theme/fancy.php

    Now you should be able to use the fancybreadcrumbs Smarty function in the copy of your default.master.tpl

  • Yeah, that's exactly what I ended up doing! Thanks again!

Sign In or Register to comment.