We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13458
    • 2 Posts
    Hi all, I’m on my first MODx project and I’m pretty excited about it.

    However, it’s quickly become apparent that there’s no way I’m going to use the code editors within MODx. I mean, I’m open to change but that’s going too far. So I’ve used a technique that allows me to edit the HTML in my code editor, hit save then look at the site to see the changes, just like I normally would. (I should point out that I do front-to-back, both design and dev).

    I just want to ask what people think of this. Will it be slower than using the database, I mean in terms of page execution times?

    Basically I used the method posted by ER in this thread: http://modxcms.com/forums/index.php?topic=10351.0

    So I have a template in MODx, which is mostly made up of includes like this:

    [[include_template? &tpl=`main/head.html`]]
    


    The snippet, "include_template", looks like this:

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


    So what do you think? Are there many others who work like this? Frankly I’m wondering why everyone doesn’t use files rather than chunks, but maybe I’m missing something (I’m only two days in).
      • 13458
      • 2 Posts
      Well, after using this technique for a while I decided to ditch it in favour of the "It’s All Text" Firefox add-on, which allows me to edit the contents of the chunk and template textarea boxes in my code editor without the need for an actual file. I think this was suggested elsewhere on this forum.

      https://addons.mozilla.org/en-US/firefox/addon/4125

      This seems better architecturally. After my initial resistance, it now feels more comfortable just to go along with the MODx way of doing things. Also it seems a lot faster now that the HTML is being cached.

      However, like others I still use includes for snippets.