We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15001
    • 697 Posts
    Whow, this seems really powerful !

    A priori, I think that getting the content from the file system is not slower than from the database.
    I read somewhere that storing pictures in databases (as BLOBs) is huge mistake in term of speed. So, I assume that storing templates in external files is also not worse than in the DB.
    In all cases, heliotrope’s plugin is very nice for development speed.
      • 7231
      • 4,205 Posts
      Works great. Thanks for the update smiley
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 30223
        • 1,010 Posts
        Because you use include() to fetch the template form the file system you realize that you can PHP inside the template?

        Having this in your main template (fetched using @FILE:main.tpl for instance)
        <?php include('header.tpl'); ?>
        [*content*]
        <?php include('header.tpl'); ?>
        

        works just as well as (if not faster) than
        @FILE:header.tpl
        [*content*]
        @FILE:footer.tpl
        


        The other thing to be mindful about is that the result will be cached so if you change the footer.tpl file for instance the changes will not be seen until after you clear the cache in the manager.
          • 3749
          • 24,544 Posts
          Quote from: TobyL at Feb 01, 2009, 08:20 PM

          Because you use include() to fetch the template form the file system you realize that you can PHP inside the template?

          Having this in your main template (fetched using @FILE:main.tpl for instance)
          <?php include('header.tpl'); ?>
          [*content*]
          <?php include('header.tpl'); ?>
          

          works just as well as (if not faster) than
          @FILE:header.tpl
          [*content*]
          @FILE:footer.tpl
          


          The other thing to be mindful about is that the result will be cached so if you change the footer.tpl file for instance the changes will not be seen until after you clear the cache in the manager.

          Interesting idea. I’m not sure it wouldn’t be slower since you’d be doing three separate file accesses/reads and two calls to the PHP server versus one DB query.
            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
            • 25663 MODX Staff
            • 12,272 Posts
            I think templates are cached though into the sitecache, so it’d be a one-time hit. Can someone please verify this?
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 30223
              • 1,010 Posts
              Interesting idea. I’m not sure it wouldn’t be slower since you’d be doing three separate file accesses/reads and two calls to the PHP server versus one DB query.

              Sorry,..? separate file accesses? Are you saying that with 3 @FILE: statements you are not making 3 separate file accesses? I see no difference there. As far as the 2 calls to the php engine are concerned I’m not so sure that this would add any extra overhead compared with parsing the template multiple times. The fact that you are using an include means it’s parsed by php anyway. All that’s happening is that php is ignoring the bits outside the php tags. I haven’t done any benchmarking but I suspect it’s comparing apples with apples.

              Anyway I was simply pointing out something. It wasn’t a criticism.

              Quote from: rthrash at Feb 02, 2009, 06:06 AM

              I think templates are cached though into the sitecache, so it’d be a one-time hit. Can someone please verify this?

              If the page is cached yes. The template (and the result of this plugin) is cached as part of the page content. So either way in most cases it would be a one-time hit.

                • 3749
                • 24,544 Posts
                Quote from: TobyL at Feb 02, 2009, 08:24 AM

                Interesting idea. I’m not sure it wouldn’t be slower since you’d be doing three separate file accesses/reads and two calls to the PHP server versus one DB query.

                Sorry,..? separate file accesses? Are you saying that with 3 @FILE: statements you are not making 3 separate file accesses? I see no difference there. As far as the 2 calls to the php engine are concerned I’m not so sure that this would add any extra overhead compared with parsing the template multiple times. The fact that you are using an include means it’s parsed by php anyway. All that’s happening is that php is ignoring the bits outside the php tags. I haven’t done any benchmarking but I suspect it’s comparing apples with apples.

                Anyway I was simply pointing out something. It wasn’t a criticism.

                I didn’t mean to start an argument, I was just thinking out loud. When I said "three separate file accesses/reads and two calls to the PHP server versus one DB query," I should have made it clear that I was comparing the speed of the new method to that of the standard MODx method where the whole template is in a single DB record.
                  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
                  • 30223
                  • 1,010 Posts
                  Nor did I in my slighly terse reply smiley It’s 3:00 am here and I’m supposed to be asleep. Totally misunderstood the comparison. grin
                    • 3749
                    • 24,544 Posts
                    No sweat. I’ve been there. grin
                      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
                      • 4971
                      • 964 Posts
                      Can somebody please explain in easier terms for the not so advanced people like me what
                      is the difference of this method and including the template direct from the file system?

                      When I define my templates I use the includeFile snippet and in the template I have
                      a bunch of template variables for each section of the page/site... like [*footer*]
                      then I place chunks for the parts of the page like {{leftFooter}}, {{middleFooter}}, {{rightFooter}}

                      The only advantage I am seeing is that the chunks could be in the file system as well, using
                      the @File construct...
                        Website: www.mercologia.com
                        MODX Revo Tutorials:  www.modxperience.com

                        MODX Professional Partner