We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27330
    • 884 Posts
    Hello all,
    I have 3 contact forms on a site, we usually reply to forms withing few hours and clients are expecting that.
    sometimes I want to display a message that we will be closed until dd/mm/yyyy at hh:mm and will reply then due to holiday or whatever reason.

    right now I have a checkbox TV which calls a chunck named $closedUntil which I need to enable on all three form pages.

    Which approach will you go with if you were me and wanted to enable certain TV on several pages with single click?

    I thought about having the chunk directly in the code but have it mis-spelled in the backend when I don't want the message to display, this will work but sounds too dirty IMO. I would love to hear some suggestion if anyone has any!
    Thank you

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

      • 4172
      • 5,888 Posts
      you could enable/disable the chunk-display by a system-setting or a clientConfig-setting
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • discuss.answer
        • 3749
        • 24,544 Posts
        To expand on Bruno17's answer, A text System Setting (let's call it closed_until) and a snippet something like this would be how I would do it:

        Add this to the closedUntil chunk:

        <p>We will be closed until [[+back_date]]</p>


        <?php
        $closed = $modx->getOption('closed_until');
        
        if (empty($closed)) {
            $output = '';
        } else {
            $output = $modx->getChunk('closedUntil', array('back_date' => $closed));
        }
        
        return $output;


        The System Setting will be empty normally, but contain the date you'll be back otherwise.

        The terse, slightly more efficient, version would be:

        $closed = $modx->getOption('closed_until');
        return empty($closed)? '' : $modx->getChunk('closedUntil', array('back_date' => $closed));

          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
          • 27330
          • 884 Posts
          Thank you both. great ideas. @BobRay love the expansion!
          tested and work sweet!
            • 3749
            • 24,544 Posts
            I'm glad I could help. 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