Last active
August 29, 2015 14:02
-
-
Save dsalvagni/901e23a079e6206748f1 to your computer and use it in GitHub Desktop.
Arquivos para incluir uma assinatura de newsletter com lightbox no Magento. Mais em: www.dsalvagni.com.br/magento-adicionar-pop-up-assinatura-newsletter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Definimos que o cliente ainda não assina a newsletter */ | |
$customerSubscribed = false; | |
/* Verifica se está logado */ | |
if(Mage::getSingleton('customer/session')->isLoggedIn()) | |
{ | |
/* Retorna o e-mail do cliente */ | |
$Email = Mage::getSingleton('customer/session')->getCustomer()->getEmail(); | |
/* Verifica se já assina */ | |
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($Email); | |
if($subscriber->getId()) | |
{ | |
/* Assina */ | |
$customerSubscribed = true; | |
} | |
} | |
/* Definimos que ainda não foi exibido */ | |
$newsletterShowed = false; | |
/* Verificamos se existe o cooke */ | |
$mageCookie = Mage::getModel('core/cookie'); | |
if(!$mageCookie->get('dsalvagni-newsletter-ligthbox')) | |
{ | |
/* Definimos o cookie */ | |
$mageCookie->set('dsalvagni-newsletter-ligthbox', 'shown',time()+86400); | |
} | |
/* Cookie existe. Marcamos como já exibido. */ | |
else $newsletterShowed = true; | |
?> | |
<!-- OVERLAY --> | |
<div class="dsalvagni-newsletter-lightbox-overlay" id="dsalvagni-newsletter-lightbox-overlay" <?php echo ($customerSubscribed || $newsletterShowed) ? 'style=" display:none; "' : null; ?>></div> | |
<!-- LIGHTBOX CONTAINER --> | |
<div class="dsalvagni-newsletter-lightbox-box" id="dsalvagni-newsletter-lightbox-box" <?php echo ($customerSubscribed || $newsletterShowed) ? 'style=" display:none; "' : null; ?>> | |
<!-- X CLOSE --> | |
<a href="javascript:;" class="dsalvagni-newsletter-lightbox-close-action dsalvagni-newsletter-lightbox-close">X</a> | |
<!-- /X CLOSE --> | |
<!-- FORM NEWSLETTER --> | |
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="dsalvagni-newsletter-lightbox-form" onsubmit="dsalvagni_newsletter_lightbox_onSubmit(this); return false;"> | |
<div class="dsalvagni-newsletter-lightbox-content"> | |
<div class="dsalvagni-newsletter-lightbox-header"> | |
<label for="newsletter"><?php echo $this->__('Sign Up for Our Newsletter:') ?></label> | |
</div> | |
<div class="input-box"> | |
<input type="text" name="email" id="newsletter-email" title="<?php echo $this->__('Sign up for our newsletter') ?>" class="input-text required-entry validate-email" /> | |
</div> | |
<div class="actions"> | |
<button type="submit" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Subscribe') ?></span></span></button> | |
<!-- CLOSE BUTTON --> | |
<button type="button" title="<?php echo $this->__('Close') ?>" class="button dsalvagni-newsletter-lightbox-close-action"><span><span><?php echo $this->__('Close') ?></span></span></button> | |
<!-- /CLOSE BUTTON --> | |
</div> | |
</div> | |
</form> | |
<!-- MENSAGEM DE RETORNO --> | |
<div class="dsalvagni-newsletter-lightbox-return" id="dsalvagni-newsletter-lightbox-return"> | |
</div> | |
<!-- /MENSAGEM DE RETORNO --> | |
<!-- /FORM NEWSLETTER --> | |
<script type="text/javascript"> | |
//<![CDATA[ | |
var newsletterSubscriberLightboxFormDetail = new VarienForm('dsalvagni-newsletter-lightbox-form'); | |
//]]> | |
</script> | |
</div> | |
<!-- /LIGHTBOX CONTAINER --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<layout version="0.1.0"> | |
<!-- Inserindo as alterações na home da loja --> | |
<!-- Para exibir em todas as páginas, alterar "cms_index_index" para "default" --> | |
<cms_index_index> | |
<!-- Arquivos CSS e JS sendo incluídos somente para esta página --> | |
<reference name="head"> | |
<action method="addItem"><type>skin_js</type><name>js/dsalvagni-newsletter-lightbox.js</name><params/></action> | |
<action method="addItem"><type>skin_css</type><name>css/dsalvagni-newsletter-lightbox.css</name><params/></action> | |
</reference> | |
<!-- Inserindo o lightbox no CONTENT, mas pode ser em outro --> | |
<reference name="content"> | |
<block type="newsletter/subscribe" name="dsalvagni.lightbox.newsletter" template="newsletter/lightbox.phtml"/> | |
</reference> | |
</cms_index_index> | |
</layout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment