Jump to content

Embed A Custom Form In Sidebar


Recommended Posts


<div class="headerForm">
    <form id="searchbox" action="" method="post" class="contact-form-box" enctype="multipart/form-data">
  <div class="form-group">
  <div><h1 style="color:#ef0f0f; width:250px; margin: 20px 25px 25px 25px">Request A Quote</h1></div>
    <label style="color:#fff; padding-right:5px;margin " for="name">First Name: </label>
    <input style="text-transform: capitalize" "type="text" name="firstName" class="search_query ac_input" id="fname">
  </div>
<div class="form-group">
    <label style="color:#fff; padding-right:5px" for="name">Last Name: </label>
    <input style="text-transform: capitalize" type="text" name="lastName" class="search_query ac_input" id="lname">
  </div>
  <div class="form-group">
    <label style="color:#fff; padding-right:5px" for="pwd">Email:         </label>
    <input type="email" required class="search_query ac_input" name="email" id="email">
  </div>
<div class="col-xs-12 col-md-9">
                <div class="form-group">
                    <label style="color:#fff; padding-right:5px"  class="mess" for="message">{l s='Your Enquiry: '}   </label>
                    <textarea style=" text-transform:capitalize; required max-width: 65% !important; min-width: 150px !important; width: 65% !important;" class="textform" id="message" name="message">{if isset($message)}{$message|escape:'html':'UTF-8'|stripslashes}{/if}</textarea>
                </div>
 </div>

 <div class="form-group">
    <label style="color:#fff; padding-right:5px" for="pwd">Vehicle Registration:      </label>
    <input style="text-transform: uppercase" type="text" class="search_query ac_input" name="vehicle_registration" id="vehicle_registration">
  </div>
  <div class="form-group">
    <label style="color:#fff; padding-right:5px" for="pwd">Vehicle Make:      </label>
    <input  style="text-transform: capitalize" type="text" class="search_query ac_input" name="vehicle_make" id="vehicle_make">
  </div>
  <div class="form-group">
    <label style="color:#fff; padding-right:5px" for="pwd">Vehicle Model:      </label>
    <input style="text-transform: capitalize" type="text" class="search_query ac_input" name="vehiclemodel" id="vehiclemodel">
  </div>
 <div class="form-group">
    <div class="element-wrap clearfix" id="email_area">
                                    <div class="element-box">
                                        <div class="input-group">
                            <label style="color:#fff; padding-right:5px" for="name">Add Parts:    </label>
                            <input style="text-transform: capitalize" type="text" name="products[0]" required class="form-control" placeholder="" id="lname">
                            <a id="addMoreEmail" style="color:#fff;" class="btn"><strong>+</strong></a>
                          </div>
                      </div>
                  </div>
           
  
<div class="submit" style="width:200px; padding-bottom:50px;  ">
            <button type="submit" name="sendmail" id="sendmail" style="float:right; width:100px" class="button btn btn-default button-medium"><span>{l s='Send'}<i class="icon-chevron-right right"></i></span></button>
        </div>
</form>
</div>

<style>
.headerForm form {
    float: right;
    margin-left:660px;
    left: auto;
    right:auto;
    position: absolute;
    top: 324px;
    width: 300px;
    z-index: 101;
    background:#343336;
    
    
}
.mess{
vertical-align: top;
}

.headerForm .form-group {
    margin-bottom: 18px;
    width:250px;
    margin-left:25px;
    margin-right:25px;
    
}



</style> 

Hello, i have a form on my homepage that i would like to also display on all other pages in my right sidebar.

 

I have installed the addon contentBox which allows me to add the following code, but for some reason it does not work correctly. 

 

The data isnt sent to my back office like it does from the front page

 

Please see image also

 

Thanks Chris

post-632913-0-36547800-1443384747_thumb.jpg

Link to comment
Share on other sites

I am not familiar with contentBox module but I guess that its a simple module that allow you to add html/js/css content to display in the front office.

So probably that module escape the render content which mean that you cannot really add any smarty syntax like translations & if statements.

Also how do you intend to process the results on the server side?

Link to comment
Share on other sites

Managed to fix the issue, added the following code to the cmsController.php under

 

public function initContent()

{
 
$customer = $this->context->customer;
        if (Tools::isSubmit('sendmail'))
		{
			$posData = array();
			$posData = $_POST;
			$saveArray = array();
			/*if(!empty($customer->id))
			{*/
				$customer = json_decode(json_encode($customer),true);
				$id_shop = 1;//$customer['id_shop'];
				$id_lang = 1;//$customer['id_lang'];
				$email   = $_POST['email'];
				$id_customer = 0;//$customer['id'];
				$status     = 'open';
				$dateadd 	= date('Y-m-d H:i:s');
				$dateupdate 	= date('Y-m-d H:i:s');	
				/*$token    = otpKey(9);*/
                                 
				$unique_num = '';
				$keys = array();
			    $keys  = array_merge(range(0, 9), range('A', 'Z'));
			    
			    for ($i = 0; $i < 8; $i++) {
			        $unique_num .= $keys[array_rand($keys)];
			    }
				$token  = $unique_num; 

				Db::getInstance()->executeS("INSERT INTO `ps_customer_thread`(`id_shop`, `id_lang`, `id_contact`, `id_customer`, `id_order`, `id_product`, `status`, `email`, `token`,date_add,date_upd) VALUES ($id_shop,$id_lang,0,$id_customer,0,0,'".$status."','".$email."','".$token."','".$dateadd."','".$dateupdate."')",'INSERT');
				$id_customer_thread = Db::getInstance()->Insert_ID(); 
				//echo $id_customer_thread;
				//$message = $_POST['message'];
				$parts = $_POST['products'];
				$parts = implode(",", $parts);
				$message = '';
				$message = "To Bob & Chris - Customer : ( ".$_POST['firstName']." ".$_POST['lastName']." ) has requested a quote for parts on the following Vehicle Registration: ( ".$_POST['vehicle_registration']." ) - Vehicle Make: ( ".$_POST['vehicle_make']." ) - Vehicle Model ( ".$_POST['vehiclemodel']." ) - Parts Requested : ( ".$parts." ). - Customers Message: ( ".$_POST['message'].". ) - Respond to customer at: ".$_POST['email'].".";
				
				Db::getInstance()->executeS("INSERT INTO `ps_customer_message`(`id_customer_thread`, `id_employee`, `message`,  `date_add`, `date_upd`) VALUES ($id_customer_thread,0,'".$message."','".$dateadd."','".$dateupdate."') ");	
			//}
			/*else
			{
				header('Location: http://staffordfloors.co.uk/testsites/theonlinecarpartsbrokerprestashop/login');
			}*/
		}
 
 
 
}
Edited by Stokie Worm (see edit history)
Link to comment
Share on other sites

I am not familiar with contentBox module but I guess that its a simple module that allow you to add html/js/css content to display in the front office.

So probably that module escape the render content which mean that you cannot really add any smarty syntax like translations & if statements.

Also how do you intend to process the results on the server side?

Thanks for your reply, i managed to fix it, all i need to do is style it now which should be straight forward

Link to comment
Share on other sites

×
×
  • Create New...