We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50105
    • 13 Posts
    I am building a sports website that receives a high volume of traffic around game time.
    The site homepage design and components need to change depending on what stage the game it is at. The homepage has 5 different states; pre-game, build-up, game time, reaction and match report. Each one has very different functionality.

    For example before the game (Build-up) it will have a countdown time header, pre game news carousel, selected team news, etc. During the game (Game-Time) design needs to change to have a live score in the header, game reaction and video carousels and many other different components.

    My question is what is the most performant way to build this for visitors for fast load times, while making it easy for the client to update?

    Do I build out all the chunks in one template and have the client change a template variable so I can output the chunks accordingly? Would this slow down page load times having to process too much? Is it wiser to build out 5 different templates and just have the client change the template when they need to? Could I possibly cache more doing it this way?

    Thanks

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

      • 46886
      • 1,154 Posts
      It seems to me to be a tv that judges the state and applies the new template

      Well it could be a custom script with php too probably.

      In this case I don't see the template in the tv so it wouldn't be heavy I don't think. The tv can just trigger the applied template to load and so the only overhead is the one query to know the proper state.

      I don't know about caching myself
        • 3749
        • 24,544 Posts
        Another way to do it would be to make them separate pages (possibly with some shared chunks). That way they could be cached. You could change the site_start System Setting (either manually, or with a snippet or plugin) to send users to the correct page. I think that might make it easier on the client.
          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
          • 50105
          • 13 Posts
          I never thought about making them different pages. It would make it easier for the client to setup in advance.

          So I could have 5 different pages, 4 unpublished. I would need create snippet/plugin to allow the client to change the site_start to the correct one and publish that page while also unpublishing the other, then clear system_settings cache for this to take effect.

          Would there be any knock-on effect to clearing system_settings while logged into the manager or is it just the same as clear cache button in the manager?

          Thanks
          • discuss.answer
            • 3749
            • 24,544 Posts
            Clearing the System Settings cache shouldn't cause any trouble.

            Instead of publishing and unpublishing everything, you could just put an uncached snippet call on all five pages for this snippet:

            $ss = $modx->getOption('site_start');
            if ($modx->resource->get('id') != $ss) {
                $url = $modx->makeUrl($ss, "", "", "full");
                $modx->sendRedirect($url);
            }
            
            return "";


            That should always forward them to the currently active page. You might want to add the time as a parameter on the end of the URL to get past the browser cache.

            Then you could use Mark Hamstra's ClientConfig to let the client set the site_start. I don't know if it clears the SS cache.
              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
              • 50105
              • 13 Posts
              I have used ClientConfig a number of times to add extra settings but never to alter an existing site setting. How would I go about this?

              [ed. note: lightweight30 last edited this post 5 years, 7 months ago.]
                • 3749
                • 24,544 Posts
                Sorry, I've never actually used ClientConfig. I assumed that it would let you set the values of existing settings, but I could be wrong. Have you tried just filling in the form using an existing setting as described here: https://docs.modx.com/extras/revo/clientconfig
                  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
                  • 50105
                  • 13 Posts
                  It does allow you to set the values of existing settings. I never knew it could do that.

                  Thanks for your help.
                    • 3749
                    • 24,544 Posts
                    I'm glad I could help. Thanks for reporting back. smiley
                      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