We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2249
    • 60 Posts
    Hi all,

    Whenever i write a snippet nowerdays i tend to have an external file and then just include that file in the snippet using php include, which saves on tedious copy and pasting during development.

    Does anyone know if it is possible to do the same thing with chunks? I have already tried using the html include (<!--#include FILE="assets/site/chunks/mychunk.html"-->). but that doesnt seem to work sad

    Thanks in advance

    Ash
      • 4041
      • 788 Posts
      I picked up this snippet somewhere here on the forums which might help smiley (credit to original author, whomever they are)

      <?php
      # Snippet to include template files from file system
      # USAGE: [[includeTemplate? &tpl=`mytemplate/template.html`]]
      
      if ( !isset($tpl) || $tpl== "" ) return "Missing Template file!";
      
      $tpl = $base_path .'assets/templates/'.$tpl;
      ob_start();
      include($tpl);
      return ob_get_clean();
      ?>


      Whenever i write a snippet nowerdays i tend to have an external file and then just include that file in the snippet using php include, which saves on tedious copy and pasting during development.
      I’ve found using this method also helps to keep your site cache file smaller, which is always a good thing.
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 4041
        • 788 Posts
        In this case, the code I posted above would have to be in a snippet in the manager, then call that snippet in the content area of the chunk.

        For example your chunk content would be:
        [!includeTemplate? tpl=`path/to/the/file.html`!]
          xforum
          http://frsbuilders.net (under construction) forum for evolution