1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Add-on Easy header/footer includer

Discussion in 'Resource and Add-on Requests' started by Mike Creuzer, Mar 13, 2014.

  1. Mike Creuzer

    Mike Creuzer Well-Known Member

    Hey all devs!

    Looking for a plugin that will allow me to include a file from on the server (or anywhere) and include it in the page with options for a file_get_contents() and include(). I find this to be a very common thing people need to do and it'd be nice if it was in an easy to install plugin form. Not sure if this exists either I havent come across anything in the search at least.

    PM me with pricing!

    @Chris D @shadrxninga @Waindigo

    Thanks,
    Mike
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    It's more than likely possible with a callback template tag.

    This allows you to call a PHP script from a template.

    This is the basic usage. Add this to your footer template (or wherever):
    HTML:
    <xen:callback class="YourAddOn_Callback" method="renderFooter" />
    The class name is derived from the file path and file name, so the above would point to a file: library/YourAddOn/Callback.php.

    So create that file, with these contents:

    PHP:
    <?php

    class YourAddOn_Callback
    {
        public static function 
    renderFooter($content$paramsXenForo_Template_Abstract $template)
        {
            return 
    '<b>Hello Audentio!</b>';
        }
    }
    End result:

    upload_2014-3-13_23-40-19.png

    Of course there's a lot you could do aside from that...
     
    CabCon likes this.
  3. Mike Creuzer

    Mike Creuzer Well-Known Member

    Absolutely fantastic. I will give this a try tonight thanks again Chris you're as usual a life saver.
     
    CabCon likes this.
  4. Tim Davis

    Tim Davis New Member

    How safe is it to just place HTML into the header and footer files?
     
  5. Mike Creuzer

    Mike Creuzer Well-Known Member

    Depending, as safe as anything else. If someone is sending you code, be wary of it, but if you are simply editing the templates you should be fine to do as you need :)
     

Share This Page