1

This is my popup it show first time click only

How to achieve this?

<a href="#downloadme" class="fancyBoxLink">Value</a>
<div style="display:none">
    <div id="downloadme">
    <h1>Please fill following information to download files</h1>
        <form action="<?php echo $this->getUrl('downloadenquire/index/downloadme') ?>" method="post" id="download">
            <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
                <input type="text" name="name" placeholder="Name" required="true" class="input-text required-entry validate-alpha" />
                <input type="text" name="email" placeholder="Email" required="true" class="input-text required-entry validate-email"/>
                <input type="text" name="mobile" placeholder="Mobile" required="true" class="input-text required-entry validate-number"/>
            <input type="submit" value="Submit" id="submit-download" />
        </form>
    </div>
</div>



<script type="text/javascript">
jQuery(document).ready(function($) {
    $("a.fancyBoxLink").fancybox({
        'href'   : '#downloadme',
        'titleShow'  : false,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
        'openEffect'    : 'elastic',
        'closeEffect'   : 'elastic',
        'maxWidth'  : 800,
        'maxHeight' : 600,
        'fitToView' : false,
        'width'     : '35%',
        'height'    : '38%',
        'autoSize'  : false,
        'closeClick'    : false
    }); });
</script>

<script type="text/javascript">
    //< ![CDATA[
        var customForm = new VarienForm('download');
    //]]>
</script>

2 Answers 2

1

I save the cookie for popup with this function

_setCookie: function () {
        var expDate = new Date();

        expDate.setTime(expDate.getTime() + 3650000 * 60 * 1000);
        $.cookie('popup_cookie', 1, {
            expires: expDate
        });
    }

With if statement checking if cookie exsists and if exsists I don't show popup. I call this function when closed:function() runs or when success:function() runs I don't know you need it exactly or not, hope it ll help you.

0

I have another solution for your quick session cookie help: create one file in block:

app/code/local/Namespace/Module/Block/Popup.php

<?php
Class Namespace_Module_Block_Popup extends Mage_Core_Block_Template {
public function __construct() {
    parent::__construct();
    $cookie=Mage::getSingleton('core/cookie')->get("popup");        
    if (!$this->helper('customer')->isLoggedIn() && empty($cookie)){            
        $cookie_domain=Mage::getStoreConfig('web/cookie/cookie_domain');
        setcookie('wallinc','1',0,'/',$cookie_domain);
        $this->setTemplate('module/popup.phtml');
    }
  }
}

After creating this block create template in

app/design/frontend/base/default/template/module/popup.phtml

add below html code:

<div class="second-column" id="loginpage" style="display:none;">
    <div class="popoup_sidebar">

        <div class="popup_sidebar2">
           <span>Your popup</span>
        </div>
    </div>
</div>

add this fancybox script:

<script type="text/javascript">
    jQuery(document).ready(function () {
       jQuery.fancybox("#loginpage"); 
  });
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.