We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26958
    • 9 Posts
    We have a client whose site we have converted to modX, save for a couple forms. I’ll use the simpler example to show what I’m trying to do.

    We have an FAQ form where there’s a form to send your own question if your query doesn’t appear on the page. So when they submit the form, we want it to process the form and if everything is complete send an e-mail. We have the snippet of code at the very top of the template, and that works great!

    However, we want to display JUST the form if there are any errors or a thank you page after they submit rather than the content. So it should do something like this, but I don’t know how to do it here in modX:

    		<div class="content-main[[cc_tallest]]">
    if (empty($_POST['submit'])) {
    	[[clinics_confirmation]]
    } else {
    	[*content*]
    }
    		<!-- .content-main -->		
    		</div>
    


    This is probably something very simple, but I don’t know how to do it and I tried a few searches through the forums here before I posted my own message. Does anyone know how to do this?
      • 1343 ☆ A M B ☆
      • 2,213 Posts
      I don’t know much about the code aspect, but if that code will get the job done then you should be able to use it in a snippet to accomplish the desired result.

      AMDbuilder
        Patrick | Server Wrangler
        About Me: Website | Tweets |  MODX Hosting
        • 3749
        • 24,544 Posts
        A snippet would certainly do it fairly easily, but I wonder if there’s a way to do it in a single line with PHX. I’m not a PHX expert but maybe someone will chime in.

          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
          • 22303 MODX Staff
          • 10,725 Posts
          Just replace:
          if (empty($_POST['submit'])) {
          	[[clinics_confirmation]]
          } else {
          	[*content*]
          }
          with a non-cacheable snippet call:
          [!clinics_confirmation_wrapper!]
          with the code:
          <?php
          if (empty($_POST['submit'])) {
          	return $modx->runSnippet('clinics_confirmation');
          } else {
          	return '[*content*]';
          }
          ?>


          [EDIT: typo with Revo-style non-cacheable snippet tags corrected]
            • 20413
            • 2,877 Posts
            [[!clinics_confirmation_wrapper]]

            Typo! Should be:

            [[clinics_confirmation_wrapper]]

            wink
              @hawproductions | http://mrhaw.com/

              Infograph: MODX Advanced Install in 7 steps:
              http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

              Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
              http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
              • 1343 ☆ A M B ☆
              • 2,213 Posts
              As I understand the new tags for revo that is correct, but if OP is using evolution then he needs to use [!snippetname!] if I recall correctly.

              AMDbuilder
                Patrick | Server Wrangler
                About Me: Website | Tweets |  MODX Hosting
                • 26958
                • 9 Posts
                This was exactly what I was after and works like a champ. Thanks!