0
我需要幫助來實現這一點。延遲通訊彈出
我得到了一個magento模板,我的支持期已經過期,但是我偶然發現了一個我不能正確糾正的問題。
每當我的網站加載時,通訊彈出同時很惱人。我想要的是在網站完成加載後,彈出的新聞簡報延遲。並且如果可能的話,在用戶會話期間只能讓它出現一次。
如果我能在這裏得到幫助,我會很高興。
非常感謝所有。
下面是代碼
<?php
/**
Made by Smartwave.
*/
?>
<?php
$store = Mage::app()->getStore();
$code = $store->getCode();
$popup = Mage::getStoreConfig('porto_settings/newsletter_popup',$code);
?>
<script type="text/javascript">
jQuery(function($) {
var check_cookie = $.cookie('newsletter_popup');
if(check_cookie == null || check_cookie == 'shown') {
beginNewsletterForm();
}
$('#newsletter_popup_dont_show_again').on('change', function(){
if($(this).length){
var check_cookie = $.cookie('newsletter_popup');
if(check_cookie == null || check_cookie == 'shown') {
$.cookie('newsletter_popup','dontshowitagain');
}
else
{
$.cookie('newsletter_popup','shown');
beginNewsletterForm();
}
} else {
$.cookie('newsletter_popup','shown');
}
});
});
function beginNewsletterForm() {
jQuery.fancybox({
'padding': '0px',
'autoScale': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'inline',
'href': '#newsletter_popup',
'onComplete': function() {
$.cookie('newsletter_popup', 'shown');
},
'tpl': {
closeBtn: '<a title="Close" class="fancybox-item fancybox-close fancybox-newsletter-close" href="javascript:;"></a>'
}
});
jQuery('#newsletter_popup').trigger('click');
}
</script>
<style type="text/css">
<?php
if($popup["newsletter_custom_style"]){
echo $popup["newsletter_custom_style"];
}
?>
#newsletter_popup{
<?php
if($popup["newsletter_width"]){
echo "width:".$popup["newsletter_width"].";";
}
if($popup["newsletter_height"]){
echo "height:".$popup["newsletter_height"].";";
}
if($popup["newsletter_bg_color"]){
echo "background-color:".$popup["newsletter_bg_color"].";";
}
if(isset($popup["newsletter_bg_image"]) && $popup["newsletter_bg_image"]){
?>
background-image:url(<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."porto/newsletter_popup/".$popup['newsletter_bg_image'];?>);
<?php
}
?>
}
</style>
<div class="block block-subscribe" id="newsletter_popup">
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-popup-validate-detail" onsubmit="setNewsletterCookie()">
<div class="block-content">
<?php
if($popup["show_logo"]){
?>
<img src="<?php echo $this->getSkinUrl($popup["show_logo"]); ?>" alt="" />
<?php
}
?>
<?php echo $popup['newsletter_content']; ?>
<div class="input-box">
<input type="text" name="email" id="newsletter_popup_email" title="<?php echo $this->__('Sign up for our newsletter') ?>" class="input-text required-entry validate-email" placeholder="<?php echo $this->__("Email Address"); ?>" />
<button type="submit" title="<?php echo $this->__('Go!') ?>" class="button"><span><span><?php echo $this->__('Go!') ?></span></span></button>
<div class="clearer"></div>
</div>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var newsletterpopupSubscriberFormDetail = new VarienForm('newsletter-popup-validate-detail');
document.getElementById("newsletter-popup-validate-detail").onsubmit=function(){
jQuery.cookie('newsletter_popup','dontshowitagain');
}
//]]>
</script>
<div class="subscribe-bottom">
<input type="checkbox" id="newsletter_popup_dont_show_again"/>
<label for="newsletter_popup_dont_show_again"><?php echo $this->__("Don't show this popup again"); ?></label>
</div>
</div>
啊,你不能用PHP做到這一點。尋找JavaScript的延遲功能 – aron9forever