We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18397
    • 3,250 Posts
    It seems on a clean install of 0.9.1 the snippet 404form is not created??? Its code is here for reference (from the main MODx site)

    // Email / Contact Form
    // Simple XHTML validating email form, that sends different subjects and messages. 
    // people in a company.
    //
    // Version 1.0
    // September 9, 2005
    // [email protected]
    //
    
    // DO NOT ALTER THE FOLLOWING TWO LINES
    $subject_array = array();
    $recipient_array = array();
    
    ///////////////////////////////////
    //  <-----  BEGIN CONFIG  ----->
    ///////////////////////////////////
    // Edit only what's between the quotation marks in the lines below.
    // These will be the subjects that your users can choose from popup
    // lists. You can have as many as you want. Each one must be set up like so:
    // $subject_array[] = "What You Want This Choice To Be";
    // Make sure to remove empty ones that you aren't using. Just delete the entire line.
    
    // Generic email to use for all parts. You can edit
    // the individual instances for more control.
    // Can be set by using as follows:
    // [[ContactForm? &sendTo=`[email protected]`]]
    $email = (isset($sendTo))? $sendTo : '[email protected]';
    
    // enter "static" in order to use the static subject line
    $subject_type = "static";
    $static_subject = "[404 Inquiry] ".$modx->config['site_url'];
    
    // Otherwise use an array of possible subjects
    $subject_array[] = "Survey Info";
    $subject_array[] = "Company Info";
    $subject_array[] = "Other Info";
    
    // Recipient ... add or remove lines as needed
    // Format (as few or as many as desired): 
    // $recipient_array["Your Text Here"] = '[email protected]';
    
    
    // enter "static" in order to use the solo recipient
    $recipient_type = "static";
    $static_recipient = "$email";
    
    // Instructions 
    $instructions = "Please tell us what you were looking for, and fill out all of the fields so we can contact you with any follow-up questions.";
    
    // Success Message
    $success = "Thanks for contacting [(site_url)]. Someone will get back to you soon. You may submit another message in the form below.";
    
    // Class for containing Success Message <p>
    $successClass = "message";
    
    // Failure <p> class
    $failClass = "error";
    
    // Empy Field failure message
    $emptyFields = "One of the fields was left blank. Please put something in all fields.";
    
    // General failure message
    $generalFail = "Sorry, there was an error! Please try again later.";
    
    // Bad email failure message
    $emailFail = "The email address you supplied ({$_POST['email']}) does not appear to be valid. Please try again.";
    
    // Debug mode for testing
    $debug = false;
    
    //  <-----  END CONFIG  ----->
    ///////////////////////////////////
    
    // Get the page the form is on
    $formPage = $modx->documentIdentifier;
    
    if ($debug && $_POST) {
    	$SendMail .= "POST variables from Document ID {$formPage}:\n";
    	foreach ($_POST as $key => $value) {
    		$SendMail .= "\t$key => $value\n";
    	}
    } 
    
    if ($_POST['send'] == 'true') { 
        $to = ($recipient_type=="static") ? $static_recipient : $_POST['to'];
        $from = $_POST['name'];
        $from_email = $_POST['email'];
        $the_subject = ($subject_type=="static") ? "$static_subject" : $_POST['subject'];
        $message = $_POST['message'];
        if ( ($from == '')||($from_email == '')||($message == '') ) {
            $SendMail .= "<p class=\"$failClass\">$emptyFields</p>";
        } elseif (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $from_email)) {
            $subject = $the_subject;
            $headers = "From: $from <$from_email>\r\n";
            
            // clean out potential tomfoolery...
            $message = $modx->stripTags($message);
            
            $body = "Name: $from\nEmail: $from_email\nMessage:\n\n" . $message;
            if (mail($to, $subject, $body, $headers)) {
                $SendMail .= "<p class=\"$successClass\">$success</p>";
                $SendMail .= ($debug) ? "<p>$to\n$headers\n$subject\n$body</p>" : '';
                $from="";
                $from_email="";
                $message="";
            } else {
                $SendMail .= "<p class='$failClass'>$generalFail</p>";
                $send = "false";
            }
        } else {
            $SendMail .= "<p class=\"$failClass\">$emailFail</p>";
            $send = "false";
        } 
    } else {
        $SendMail .= "<p>$instructions</p>";
    }
    
    $SendMail .=<<<EOD
    <div class="emailform">
        <form method="post" name="EmailForm" id="EmailForm" action="[~{$formPage}~]" >
            <input type="hidden" name="send" value="true" />
            Your Name:<br />
            <input type="text" name="name" id="name" size="30" value="$from" /><br />
    
            Your Email Address:<br />
            <input type="text" name="email" id="email" size="30" value="$from_email" /><br />
    
            I am looking for:<br />
            <textarea cols="60" rows="10" name="message" id="message">$message</textarea><br />
    
            <input type="submit" value="Send this Message" />
        </form>
    </div>
    EOD;
    
    return $SendMail;
    • Hi Mark,

      I think it is installed but it’s called ’ContactForm’ instead, code looks the same anyway.

      Cheers, Garry
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 18397
        • 3,250 Posts
        ContactForm is a separate snippet but based on the same codebase (has one or two fewer fields and different text).
        • 404 form is only installed with the demo content.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 18397
            • 3,250 Posts
            I did install the demo content and it was no-where to be found.
              • 33175
              • 711 Posts
              Hi !

              The code you get is the "good" code. With the installation of the demo site, \n have been removed : the PHP code isn’t valid.
              To resolve it, replace the code in the snippet by the code you have quoted in your post.

              Sorry for my bad english.... undecided


                Sorry for my english. I&#39;m french... My dictionary is near me, but it&#39;s only a dictionary !