We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30837
    • 20 Posts
    Built a few aites in Modx, but was wondering...

    Is there any way to use external files as templates, as opposed to using the database? That’s one of the things I actually like about Wordpress and a couple other CMS’s... you can change the code in something like coda as opposed to doing it in the CMS...

    Thanks in advance.
    Chris
      • 4041
      • 788 Posts
      I don’t remember who actually originally provided this code, but it was here on the forums.

      <?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();
      ?>
        xforum
        http://frsbuilders.net (under construction) forum for evolution