Jump to content

Edit History

Inter Svetainė

Inter Svetainė


fixed path to FTP to add class

On 3/28/2014 at 8:40 AM, pietro said:

Last, I added this to my CmsController.php file. It goes inside the funtion function init(), I put it at the end, right after "header('Status: 404 Not Found'); }"


if (isset($_POST['quickcontact'])){
            if ( $_POST['subject'] != '' ) {
                die("ERROR");
            } else {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $message = $_POST['message'];
        $formcontent="From: $name \n Email: $email \n Message: $message";
        $recipient = "[email protected]";
        $subject = "Quick Contact Form";
         $mailheader = "From: $email \r\n";
        mail($recipient, $subject, $formcontent, $mailheader) or die("Error");
        header( 'Location: http://yourdomain.com/store/en/content/16-thank-you' ) ;
            }
        }

 

Please do not encourage editing of core files.

Create Override - in folder override/controllers/front/ create a file CmsController.

In it insert this:

class CmsController extends CmsControllerCore
{
    public function initContent(){
        parent::initContent(); // include everything what is already in core file (initContent function/method).
        if(Tools::getValue('quickcontact')){
            if ( $_POST['subject'] != '' ) {
                die("ERROR");
            } else {
              $name = $_POST['name'];
              $email = $_POST['email'];
              $message = $_POST['message'];
              $formcontent="From: $name \n Email: $email \n Message: $message";
              $recipient = "[email protected]";
              $subject = "Quick Contact Form";
               $mailheader = "From: $email \r\n";
              mail($recipient, $subject, $formcontent, $mailheader) or die("Error");
              header( 'Location: http://yourdomain.com/store/en/content/16-thank-you' ) ;
            }
        }

    }
}

In this case no updates of Prestashop core files are scared to You anymore ;)

Inter Svetainė

Inter Svetainė

On 3/28/2014 at 8:40 AM, pietro said:

Last, I added this to my CmsController.php file. It goes inside the funtion function init(), I put it at the end, right after "header('Status: 404 Not Found'); }"


if (isset($_POST['quickcontact'])){
            if ( $_POST['subject'] != '' ) {
                die("ERROR");
            } else {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $message = $_POST['message'];
        $formcontent="From: $name \n Email: $email \n Message: $message";
        $recipient = "[email protected]";
        $subject = "Quick Contact Form";
         $mailheader = "From: $email \r\n";
        mail($recipient, $subject, $formcontent, $mailheader) or die("Error");
        header( 'Location: http://yourdomain.com/store/en/content/16-thank-you' ) ;
            }
        }

 

Please do not encourage editing of core files.

Create Override - in folder override/controllers/ create a file CmsController.

In it insert this:

class CmsController extends CmsControllerCore
{
    public function initContent(){
        parent::initContent(); // include everything what is already in core file (initContent function/method).
        if(Tools::getValue('quickcontact')){
            if ( $_POST['subject'] != '' ) {
                die("ERROR");
            } else {
              $name = $_POST['name'];
              $email = $_POST['email'];
              $message = $_POST['message'];
              $formcontent="From: $name \n Email: $email \n Message: $message";
              $recipient = "[email protected]";
              $subject = "Quick Contact Form";
               $mailheader = "From: $email \r\n";
              mail($recipient, $subject, $formcontent, $mailheader) or die("Error");
              header( 'Location: http://yourdomain.com/store/en/content/16-thank-you' ) ;
            }
        }

    }
}

In this case no updates of Prestashop core files are scared to You anymore ;)

Inter Svetainė

Inter Svetainė

On 3/28/2014 at 8:40 AM, pietro said:

I needed to add a simple contact form to one CMS page and I had to put together pieces from different post. Mainly from here (thank you): http://www.prestashop.com/forums/topic/246845-solved-custom-form/

 

I was surprised to not find more strainght forward information, so I am going to summarize here what I did in case it helps someone else in the future. First you need to extend your TinyMCE, follow the link provided by vekia above.

 

I inserted the form in the HTML editor of my CMS page:


<form action="" method="post" autocomplete="off">
<div><label>NAME</label>
<div><input style="width: 220px; height: 28px;" name="name" type="text" /></div>
</div>
<br />
<div><label>BEST CONTACT</label>
<div><input style="width: 220px; height: 28px;" name="email" type="text" />
<div><spam style="font-style: italic;">(email, phone or both)</spam></div>
</div>
</div>
<br />
<div class="quickformsubject"><label>SUBJECT</label>
<div><input style="width: 220px; height: 28px;" name="subject" type="text" /></div>
</div>
<div><label>YOUR MESSAGE</label>
<div><textarea style="width: 340px; height: 100px;" name="message" rows="6" cols="25"></textarea></div>
</div>
<br />
<div><input class="button" name="quickcontact" value="Contact me" type="submit" /></div>
</form>

The SUBJECT field is a trap for spambots, it is hidden for human users, therefore it should be always empty; if robots fill it out the form dies (more info here: http://riserinteractive.com/stop-form-spam-without-captcha-or-quizzes/)

Add the following to your CSS to hide the trap field:


.quickformsubject {
    display: none;       
}

Last, I added this to my CmsController.php file. It goes inside the funtion function init(), I put it at the end, right after "header('Status: 404 Not Found'); }"


if (isset($_POST['quickcontact'])){
            if ( $_POST['subject'] != '' ) {
                die("ERROR");
            } else {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $message = $_POST['message'];
        $formcontent="From: $name \n Email: $email \n Message: $message";
        $recipient = "[email protected]";
        $subject = "Quick Contact Form";
         $mailheader = "From: $email \r\n";
        mail($recipient, $subject, $formcontent, $mailheader) or die("Error");
        header( 'Location: http://yourdomain.com/store/en/content/16-thank-you' ) ;
            }
        }

The form will redirect the user to a thank you page or any other page you select, it will not sent a confirmation email to the user. It worked for me in PS 1.5.6.1

 

Good luck,

 

 

 

Please do not encourage editing of core files.

Create Override - in folder override/controllers/ create a file CmsController.

In it insert this:

class CmsController extends CmsControllerCore
{
    public function initContent(){
        parent::initContent(); // include everything what is already in core file (initContent function/method).
        if(Tools::getValue('quickcontact')){
            if ( $_POST['subject'] != '' ) {
                die("ERROR");
            } else {
              $name = $_POST['name'];
              $email = $_POST['email'];
              $message = $_POST['message'];
              $formcontent="From: $name \n Email: $email \n Message: $message";
              $recipient = "[email protected]";
              $subject = "Quick Contact Form";
               $mailheader = "From: $email \r\n";
              mail($recipient, $subject, $formcontent, $mailheader) or die("Error");
              header( 'Location: http://yourdomain.com/store/en/content/16-thank-you' ) ;
            }
        }

    }
}

In this case no updates of Prestashop core files are scared to You anymore ;)

×
×
  • Create New...