how to add multiple newsletter in one page with magento? - magento

I want to add two newsletter in my site.One is in the footer and another one when i hover the topmenu.
I tried to add two newsletter in my page and it also worked but the problem is if i am adding another newsletter in my site then first newsletter is not working.I donot know what is the problem.
If anyone knows this, please help me out.
Thanks!
I put subscribe_footer.phtml in \app\design\frontend\default\mytheme\template\newsletter
<div class="row-7-col-1">
<h2><?php echo $this->__('newsletter') ?></h2>
<p><?php echo $this->__('Sign up to our newsletter and get exclusive deals you wont find anywhere else straight to your inbox!') ?></p>
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-footer-validate-detail-footer">
<input type="text" name="email" id="newsletter-footer" title="<?php echo $this->__('Sign up for our newsletter') ?>" class="input-text required-entry validate-email" />
<input type="submit" title="<?php echo $this->__('Submit') ?>" class="newsbtn" value="submit">
</form></div>
<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail = new VarienForm('newsletter-footer-validate-detail-footer');
//]]>
</script>
</div>
For another newsletter,I put subscribe.phtml in \app\design\frontend\default\mytheme\template\newsletter
<div class="row-7-col-1">
<h2><?php echo $this->__('newsletter') ?></h2>
<p><?php echo $this->__('Sign up to our newsletter and get exclusive deals you wont find anywhere else straight to your inbox!') ?></p>
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail">
<input type="text" name="email" id="newsletter" class="field required-entry validate-email"/>
<input type="submit" title="<?php echo $this->__('Submit') ?>" class="newsbtn" value="submit">
</form></div>
<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail');
//]]>
</script>
</div>
please check and tell me why only one newsletter validation is working

<div class="block block-subscribe">
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail_footer">
<input type="text" name="email" placeholder="Enter email" id="email_footer" class="input-text required-entry validate-email mytxt2" />
<button type="submit" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
</form>
<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail_footer = new VarienForm('newsletter-validate-detail_footer');
//]]>
</script>

Two Newsletters are working as well as validation also worked for me.
Copy the newsletter/subscribe file and rename to newsletter/subscribe2.
Then just rename the validation name on newsletter.

Related

Custom contact form gives me 404 error

I've created a custom contact form for each magento product, I've set up all the files and inserted this code inside a Magento static block:
{{block type="core/template" form_action="/PersonalizzazioniEmail/index/post/" template="catalog/product/view/form-personalizzazione.phtml"}}
Here's the form-personalizzazione.phtml
<?php $productId=$this->getRequest()->getParams();
$model = Mage::getModel('catalog/product');
$_product = $model->load($productId["id"]);
?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div>
<div class="page-title">
<h1><?php echo Mage::helper('contacts')->__('Contact Us') ?></h1>
</div>
<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
<input type="hidden" id="product" name="product" value="<?php echo $_product->getName() ?>" />
<div class="fieldset">
<h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
<ul class="form-list">
<li class="fields">
<div class="field">
<label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label>
<div class="input-box">
<input name="name" id="name" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Name')) ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
</div>
</div>
<div class="field">
<label for="email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label>
<div class="input-box">
<input name="email" id="email" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Email')) ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
</div>
</div>
</li>
<li>
<label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label>
<div class="input-box">
<input name="telephone" id="telephone" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Telephone')) ?>" value="" class="input-text" type="text" />
</div>
</li>
<li class="wide">
<label for="comment" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Comment') ?></label>
<div class="input-box">
<textarea name="comment" id="comment" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Comment')) ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
</div>
</li>
</ul>
</div>
<div class="fieldset privacy">
<ul class="form-list">
<?php if (Mage::helper('privacy')->isPrivacyEnabled()): ?>
<li>
<?php echo $this->getChildHtml('privacy.include.contacts'); ?>
</li>
<?php endif;?>
</ul>
</div>
<div class="buttons-set">
<p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
<input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
<button type="submit" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Submit')) ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var contactForm = new VarienForm('contactForm', true);
//]]>
</script>
But I get a 404 error when I submit the form, what could be the reason?
Thanks
Create a Custom Contact Form in Magento,Kindly visit below URLs.
http://inchoo.net/magento/magento-email/magento-custom-email-contact-form-with-notification-system/
http://ignaciogondra.com/2015/08/24/how-to-create-a-custom-contact-form-in-magento/
If you don't want to use custom code,You can use this paid extension.
https://www.magentocommerce.com/magento-connect/custom-contact-forms.html
You can also use this Product Question,It's might be fulfilled your requirement. This is free extension.
https://www.magentocommerce.com/magento-connect/product-question-1.html
Hope It's helpful for you.

ajax form display message

i have a form that insert in dbase what i write
here is the form,
<form id="contact-form" class="bl_form text-center" action="<?php echo "index.php?page=rooms&room=$rid&rpw=$rpw&r=$r";
?>" method="post" novalidate>
<span class="field-wrap scrollimation fade-right">
<input type="hidden" id="contact-name" name="contactName" type="text"
class="label_better requiredField" data-new-placeholder="Name" placeholder="Name" value="<?php echo "$uid"; ?>" data-error-
empty="*Enter your name">
</span>
<span class="field-wrap scrollimation fade-left">
<label class="control-label" for="contact-message">Message</label>
<textarea id="contact-message" name="message" rows="1" class="label_better
requiredField" data-new-placeholder="Message" placeholder="Message" data-error-empty="*Enter your message"></textarea>
</span>
<p class="text-center"><button name="sy2" id="submit_post" type="submit" class="btn btn-meflat
icon-left" data-error-message="Error!" data-sending-message="Sending..." data-ok-message="Message Sent"><i class="fa fa-paper-
plane"></i>Send Message</button></p>
<input type="hidden" name="submitted" id="submitted" value="true" />
<?php echo "<postfield name=\"message\" value=\"$(message)\"/>"; ?>
</form>
and i want to put a ajax code that display this message from dbase
<?php echo make_clickable($tosay)."$link_delete"; ?>
Can someone provide me an example?Thank you
Look at this
Ajax tutorial for post and get
So, the jQuery
$('body').on('submit', '#contact-form', function(){
$.post({$(this).attr("action"), $(this).serialize(), function(data){
if(data){
alert(data.message);
}
}, 'json');
return false;
});
And the server side
<?php
if($_SERVER['REQUEST_METHOD'] === 'POST'){
// do your thing here
echo json_encode(array("message" => make_clickable($tosay).$link_delete));
die();
}
?>

how to add new fieds and use existing address fields in magento custom regstration form

hi i am new to magento.. i need some help..
i am able to add address fields in form in my view(phtml file) but that fields data is not being
saved . how could i be able to save those fields?
code for address field in phtml file
<div class="form-group margin_top">
<label for="street_1" class="required col-md-4 control-label"><?php echo $this->__('Adresse') ?><em>* :</em></label>
<div class="col-md-6">
<div class="row">
<div class="col-md-3 nopaddingright">
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text form-control <?php echo $_streetValidationClass ?>" />
</div>
<div class="col-md-9 address_block">
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo $_i ?>" class="form-control input-text <?php echo $_streetValidationClass ?>" />
<?php endfor; ?>
</div>
<div class="col-md-9 nopaddingright">
<input type="text" name="city" value="<?php echo $this->escapeHtml($this->getFormData()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="form-control input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
</div>
<div class="col-md-3 address_block">
<input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text form-control validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
</div>
<div class="col-md-12">
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text form-control <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" />
</div>
</div>
</div>
2 . i also need mobile(cell) field to be added into my form how can i add that and save into my
database.
do i need to create Custom module ? please suggest me and help me
Thank you

Can't use varien

In the template register.phtml I added an input type radio for some terms and condition agreements.
This one is required.
I didn't success to use the javascript Magento’s frontend validation. I add all sort of classes but nothing worked.
Is Someone knows how to do please ? thanks
Here the html
<div class="field radiobox">
<div class="input-box">
<input type="radio" name="accept" title="<?php echo $this->__('I Agree to our Terms & Conditions') ?>" id="accept" class="radio required-entry validate-one-required-by-name validation-passed validation-failed" >
<label for="accept" class=required" ><?php echo $this->__('I Agree to our Terms & Conditions') ?></label>
</div>
</div>
<script type="text/javascript">
//<![CDATA[
new Varien.FileElement('accept');
//]]>
</script>
First of all remove all class other then required-entry
<input type="radio" name="accept" title="<?php echo $this->__('I Agree to our Terms & Conditions') ?>" id="accept" class="radio required-entry" >
And put this in your form tag, you don't need to create any javascript for this just ensure that it is under form tag, in register.phtml file magento already define validation javascript so don't put your javascript again.
#Mufaddal
<div class="account-form-wrapper registerpass">
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate" enctype="multipart/form-data" class="ctools-use-modal-processed" novalidate="novalidate">
<div class="fieldset">
<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
</div>
<?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
<div class="field">
<label for="email_address" class="required"><em>*</em>Email Address</label>
<div class="input-box">
<input type="text" name="email" id="email_address" value="<?php echo $this->escapeHtml($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" placeholder="<?php echo $this->__("Email Address") ?>" />
</div>
</div>
<div class="fields">
<div class="field">
<label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
<div class="input-box">
<input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" placeholder="Password" />
</div>
</div>
<div class="field">
<label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
<div class="input-box">
<input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="input-text required-entry validate-cpassword" placeholder="Confirm Password" />
</div>
</div>
</div>
<div class="field radiobox">
<div class="input-box">
<input type="radio" name="accept" title="<?php echo $this->__('I Agree to our Terms & Conditions') ?>" id="accept" class="radio required-entry" >
<label for="accept" class=required" ><?php echo $this->__('I Agree to our Terms & Conditions') ?></label>
</div>
</div>
__('Submit') ?>" id="form-submit">
__('maak mijn profiel aan') ?>
</form>

Number of countries for billing and Shipping to be different in Magento

I want to display some countries in shipping address and some other countries in the billing address.
I have followed the suggestion provided here .But after doing that my state/province input box doesn't appear.
Like this ->
look at line 78 ish in (path_to_magento)\app\design\frontend\default(my_skin_name)\template\checkout\onepage\shipping.phtml
and it should be like this. Maybe you deleted something -
<div class="field">
<label for="shipping:region" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="shipping:region_id" name="shipping[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
</select>
<script type="text/javascript">
//<![CDATA[
$('shipping:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
//]]>
</script>
<input type="text" id="shipping:region" name="shipping[region]" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
</div>
</div>

Resources