We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    Running into an issue with this bit of code causing a heavy load on the server & page is taking sometimes up to 20s to load [usually it's around 10s]

    <div id="socialsidebar">
    [[*SideBarOne:isnot=`none`:then=`[[$[[*SideBarOne]]]]`]]
    [[*SideBarTwo:isnot=`none`:then=`[[$[[*SideBarTwo]]]]` ]]
    [[*SideBarThree:isnot=`none`:then=`[[$[[*SideBarThree]]]]` ]]
    [[*SideBarFour:isnot=`none`:then=`[[$[[*SideBarFour]]]]` ]]
    [[*SideBarFive:isnot=`none`:then=`[[$[[*SideBarFive]]]]` ]]
    </div>
    


    The [[*SidebarXX]] items are template variables that use an @CHUNK @CHUNK SideBarOptions value to get the options for the sidebar items:

    # @CHUNK SideBarOptions content
    No Callout==none||FaceBook==SideBarFaceBook||News Letter==SideBarNewsLetter||YouTube==SideBarYouTube||Auditions==SideBarAuditions||News Archives==SideBarNewsArchives
    


    so that the site editor can "pick" which sidebar item will appear in which position, like I say - it's causing an unacceptable performance hit. If I remove this and just call the sidebar items as chunks, I get page executions back down under 2s from database and < 1s from cache.

    Is there a more performance friendly way to do this??

    [Revo 2.2]

    -thanks
    -sean
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
      • 3109 ☆ A M B ☆
      • 894 Posts
      Have you tried using the if extra? That might solve your performance issues.
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 26503
        • 620 Posts
        I did pretty much right after I posted this...

        <div id="socialsidebar">
        [[If? &subject=`[[*SideBarOne]]` &operator=`!=` &operand=`none` &then=`[[$[[*SideBarOne]]]]` ]]
        [[If? &subject=`[[*SideBarTwo]]` &operator=`!=` &operand=`none` &then=`[[$[[*SideBarTwo]]]]` ]]
        [[If? &subject=`[[*SideBarThree]]` &operator=`!=` &operand=`none` &then=`[[$[[*SideBarThree]]]]` ]]
        [[If? &subject=`[[*SideBarFour]]` &operator=`!=` &operand=`none` &then=`[[$[[*SideBarFour]]]]` ]]
        [[If? &subject=`[[*SideBarFive]]` &operator=`!=` &operand=`none` &then=`[[$[[*SideBarFive]]]]` ]]
        </div>
        


        works without the performance issue... I wonder why...
          *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

          Sean Kimball CLP, CLS.
          Technical Director / Sr. Developer | BigBlock Studios
          ._______________________________________________.
          Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
          27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
          phone/fax: 905-426-5525
          • 3749
          • 24,544 Posts
          I think a single checkbox TV would perform better and do the same thing, though maybe I'm misunderstanding what you're trying to do.

          I think a MIGX TV would also perform faster and do the job.


          You could also have a single TV called SideBars with a comma-separated list containing the names of the SideBars to show in the order you want to show them.

          For example, SideBars TV content:

          SideBarOne,SideBarThree,SideBarFive


          Then use this snippet:

          [[!ShowSideBars? &bars=`[[*SideBars]]`]]


          <?php
          /* ShowSideBars snippet */
          
          $bars = explode(',', $scriptProperties['bars']);
          
          $output = '';
          foreach ($bars as $bar) {
              $output .= $modx->getChunk($bar);
          }
          return $output;





          ---------------------------------------------------------------------------------------------------------------
          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
            • 26503
            • 620 Posts
            You can take a look and see how the sidebar items work [facebook, youtube etc] - http://entertainmentrevue.com just click around the site and notice that they change positions from page to page ... the thing was is that needed the client/administrator to be able to change the order and number of items ... using the [[If]] extra seems to have solved the performance issue... but basically the admin/user goes to their resource -> template variables -> [I've stored these in a "Page Options" category] and then has five drop down controls each listing all the available sidebar items ~ that way they can select which items they want to show...

            -sean
              *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

              Sean Kimball CLP, CLS.
              Technical Director / Sr. Developer | BigBlock Studios
              ._______________________________________________.
              Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
              27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
              phone/fax: 905-426-5525