We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    I'm having a great deal of trouble with formit, if I try to use an input/output filter to dynamically display a chunk containing a formit call & form, modx returns an empty page *IF* the formit call contains any "@" characters.

    For example, this:

    // if id is not homepage then use different chunk
    [[*id:neq=`1`:then=`[[$pageContent]]`]]


    $pageContent:

    <div class="row">
      <div class="col-md-12">
    
    	[[*isfolder:eq=`1`:then=`
    	[[getResources? &tpl=`salonTpl` &sortdir=`asc` &includeTVs=`1` &processTVs=`1` &depth=`1`]]`
    	:else=`[[$simpleContent]]`]]
    		
      </div>
    </div>


    $simpleContent

    <div class="col-md-8 col-sm-12">
    
    <h1 class="heading-red">[[*longtitle:default=`*pagetitle`]]</h1>
    
    [[*id:eq=`17`:then=`[[$contactForm]]`]]
    
    [[*content]]
    
    </div>




    And finally $contactForm:

    [[!FormIt?
       &hooks=`spam,email,redirect`
       &emailTpl=`ContactFormEmailTpl`
       &emailTo=`[email protected]`
       &emailSubject=`A new contact form submission has been sent`
       &emailFrom=`[email protected]`
       &emailReplyTo=`[email protected]`
       &submitVar=`submit`
       &errTpl=`inlineError`
       &validate=`name:required,email:email:required,phone:required,comments:required`
       &redirectTo=`36`
    ]]
    
    [[!+fi.validation_error_message]]
    
    <form name="contactform" class="form-horizontal contact" role="form" action="/[[~[[*id]]]]" method="post" >
    
    <!-- form fields removed for readability -->
      
    </form>






    How do I fix this?




    [ed. note: sean69 last edited this post 12 years, 7 months ago.]
      *** 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
      It may not be causing your problem, but when output modifiers are involved, you need to put everything on one line or the output modifier parser will throw a fit.

      [[*isfolder:eq=`1`:then=`
          [[getResources? &tpl=`salonTpl` &sortdir=`asc` &includeTVs=`1` &processTVs=`1` &depth=`1`]]`
          :else=`[[$simpleContent]]`]]
      
      would have to be:

      [[*isfolder:eq=`1`:then=`[[getResources? &tpl=`salonTpl` &sortdir=`asc` &includeTVs=`1`  processTVs=`1` &depth=`1`]]`:else=`[[$simpleContent]]`]]



      That said, I'd be inclined to do it with a snippet, which should be much faster and easier to understand. Something like this:

      $output = '';
      
      if (modx->resource->get('isfolder')) {
         $output = $modx->getChunk('simpleContent');
      } else {
        $fields = array(
          'tpl' => 'salonTpl',
          'sortdir' => 'asc',
          'includeTVs' => '1',
          'processTVs' => '1',
          'depth' => '1'
        );
        $output = $modx->runSnippet('getResources', $fields);
      }
      
      return $output;
      



        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
        I see what you are getting at Bob, I would up placing just the formit call in the header of my template. works fine like that [but it is loaded on every page, not sure if I should be concerned about that.

        Never had any issues with breaking placeholders across lines, I do stuff like this all the time with no issues:

        <div class="wrapper content">
          
          <div class="container">
        	
        	<div class="row">
        	
        		<!-- single column salon page-->
        		[[*layoutOverride:eq=`salon`:then=`
        			<div class="col-md-12">
        				[[getResources? 
        					&tpl=`salonTpl` 
        					&sortdir=`asc` 
        					&includeTVs=`1` 
        					&processTVs=`1` 
        					&depth=`1`
        				]]
        			</div>
        		`]]		
        		
        		<!-- two column staff page-->
        		[[*layoutOverride:eq=`staff`:then=`
        			<div class="col-md-12">
        			
        				[[!getStaff? &dps=`001,002` &phs=`ac001,ac002` &parent=`14`]]
        				
        				<div class="row">
        				
        					<div class="col-sm-6">
        				
        						<div class="panel-group" id="accordion-data-parent-001">
        				
        							[[+ac001]]
        				
        						</div>
        				
        					</div>
        				
        					<div class="col-sm-6">
        				
        						<div class="panel-group" id="accordion-data-parent-002">
        				
        							[[+ac002]]
        						
        						</div>
        					
        					</div>
        				
        				</div>
        								
        			</div>
        		`]]	
        	
        		<!-- two column contact page-->
        		[[*layoutOverride:eq=`contact`:then=`
        			<div class="col-md-8 col-sm-12">
        			
        				<h1 class="heading-red">[[*longtitle:default=`[[*pagetitle]]`]]</h1>
        				
        				[[$contactForm]]
        			
        			</div>
        			
        			<div class="col-md-4 hidden-sm hidden-xs">
        			
        			</div>
        		`]]		
        
        		<!-- two column defaut page-->
        		[[*layoutOverride:eq=`twocolumn`:then=`
        			<div class="col-md-8 col-sm-12">
        			
        				<h1 class="heading-red">[[*longtitle:default=`[[*pagetitle]]`]]</h1>
        				
        				[[*content]]
        			
        			</div>
        			
        			<div class="col-md-4 hidden-sm hidden-xs">
        			
        			</div>
        		`]]
        		
        		<!-- single column default page-->
        		[[*layoutOverride:onecolumn=`14`:then=`
        			<div class="col-md-12">
        				
        				
        				
        			</div>
        		`]]
        		
        	  </div><!-- row -->
        
          </div>
        
        </div>
          *** 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
          You can break modifiers in certain ways. You can put a line break inside the back-ticks, but last time I checked, you couldn't have a break before or after the colon, or IIRC anywhere outside the backticks. Maybe the parser has been improved since then. [ed. note: BobRay last edited this post 12 years, 7 months ago.]
            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
            • 8274 ☆ A M B ☆
            • 222 Posts
            IIRC, the format snippet will only run if the submitVar is sent via POST. otherwise it does nothing.