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

    Using 2.1.3pl to build a site.
    With multiple developers we are finding it very hard to work on templates without overwritting each others changes and messing up the pages and DB. Moving to 2.2 is not an option for this project (but due to static resources would solve our problem!!)t, so we need a quick fix for this project.

    Dug up this post:
    https://forums.modx.com/index.php?topic=40053.0

    It uses a snippet to load in a template file.
    The file can then exist on the file system as normal and we can edit and store in version control.

    The question is:
    Is there any overhead or performance issues with this approach?
    Will it effect caching etc in snippets within the tpl file, as its all now wrapped in an outer snippet call?

    Thanks in advance.

    J

    This question has been answered by BobRay. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      By template, do you mean a Tpl chunk? That's technically not a template in MODX (though it's very template-like).

      If you are getting a Tpl chunk with $modx->getChunk(), it is fairly fast, and if the page and the snippet are cached, you shouldn't see any speed difference.


      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODx info for everyone: http://bobsguides.com/MODx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        I think he's referring to the actual template, BobRay. And I don't expect that there would be a measurable difference in performance in loading the template via an include snippet.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 3749
          • 24,544 Posts
          I thought so at first, but then he mentioned "tpl file", so I'm not sure.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 15083
            • 697 Posts
            No im talking about the template.
            Just wondering if the approach of loading up a template file: mynewtemplate.blah

            QWill this approach have any performance issues, as the parser is essentially dealing with just one snippet containing everything?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              The way that works is that the resource requested is fetched from the database (if it's not cached, that is). Then its template as specified in the "template" field is fetched and processing begins. With Evo, the snippet would be run through the PHP eval() function, but I believe Revo handles snippet (and plugin) code differently. Anyway, the template's snippet will be processed, returning the full template. Then that is processed as usual. So all it does is add one brief step to the parsing process. I seriously doubt it would add a significant load to the server, nor would it take more than a fraction of a millisecond.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 15083
                • 697 Posts
                Quote from: sottwell at Jan 22, 2012, 10:34 AM
                I seriously doubt it would add a significant load to the server, nor would it take more than a fraction of a millisecond.

                Thanks Susan, initial testing for me has been fine. Non slowdown so far.
                I would imagine the new static elements in 2.2 is not a million ways away from this anyway!
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  It skips the step of loading then writing the snippet's code to file and including it. What static resources do is to simply store the path to the file and use that instead of a field from the database. So except for snippets, it really doesn't make a great deal if difference as far as the parsing process goes.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org