页面加载显示ajax中的Magento静态块

页面加载显示ajax中的Magento静态块,ajax,magento,Ajax,Magento,我正在运行Magento 1.7,它是一个新版本 我想要达到的目标: 在网站的页面加载上,显示新闻稿模板块 {{block type=“newsletter/subscribe”template=“newsletter/subscribe.phtml”} 作为Magento中的一个弹出窗口,Cookie将在给定的时间段后过期,例如:1周 网络上的答案要么不够具体,要么不够详细,因为我对脚本的了解不够广泛 到目前为止,我尝试的是: 尝试添加灯箱: 1) 添加Lightbox CSS&JS

我正在运行Magento 1.7,它是一个新版本

我想要达到的目标: 在网站的页面加载上,显示新闻稿模板块

{{block type=“newsletter/subscribe”template=“newsletter/subscribe.phtml”}

作为Magento中的一个弹出窗口,Cookie将在给定的时间段后过期,例如:1周

网络上的答案要么不够具体,要么不够详细,因为我对脚本的了解不够广泛

到目前为止,我尝试的是:

尝试添加灯箱: 1) 添加Lightbox CSS&JS

    <script type="text/javascript" src="<?php echo $this->getJsUrl('lightbox/lightbox.js'); ?>"></script>

<link rel="stylesheet" type="text/css" href="<?php echo $this->getJsUrl('lightbox/lightbox.css'); ?>" media="screen"/>

我已使用以下步骤成功调用了由静态块组成的弹出窗口

因此,基本上我们需要:

  • 添加.js和.css文件-我正在使用colorbox
  • 定义函数
  • 调用函数
  • 1) 在页眉中添加以下脚本

    <link rel="stylesheet" type="text/css" href="<?php echo $this->getJSUrl('pop/colorbox.css'); ?>" media="screen"/>
    <link rel="stylesheet"  type="text/css" href="<?php echo $this->getJSUrl('pop/popup.css'); ?>" />
    <script language="javascript" src="<?php echo $this->getJSUrl('pop/colorbox.js'); ?>"></script>
    
    <script>
    jQuery(document).ready(function (){
     if (document.cookie.indexOf('visited=true') == -1){
          var fifteenDays = 1000*60*60*24*15; 
          var expires = new Date((new Date()).valueOf() + fifteenDays);
          document.cookie = "visited=true;expires=" + expires.toUTCString(); 
          jQuery.colorbox({width:"580px", inline:true, href:"#subscribe_popup"});
          }
          jQuery(".open_popup").colorbox({width:"580px", inline:true, href:"#subscribe_popup"});
          });
    </script>
    

    您能否发布您迄今为止尝试过的代码,以便我们了解您的进展。您好,我编辑了代码,我只做了一个基本的弹出窗口。很好地解决了您自己的问题,但是这个解决方案的AJAX功能是什么?在我看来,您正在以隐藏视图呈现内容,然后按需显示。
    
    <link rel="stylesheet" type="text/css" href="<?php echo $this->getJSUrl('pop/colorbox.css'); ?>" media="screen"/>
    <link rel="stylesheet"  type="text/css" href="<?php echo $this->getJSUrl('pop/popup.css'); ?>" />
    <script language="javascript" src="<?php echo $this->getJSUrl('pop/colorbox.js'); ?>"></script>
    
    <script>
    jQuery(document).ready(function (){
     if (document.cookie.indexOf('visited=true') == -1){
          var fifteenDays = 1000*60*60*24*15; 
          var expires = new Date((new Date()).valueOf() + fifteenDays);
          document.cookie = "visited=true;expires=" + expires.toUTCString(); 
          jQuery.colorbox({width:"580px", inline:true, href:"#subscribe_popup"});
          }
          jQuery(".open_popup").colorbox({width:"580px", inline:true, href:"#subscribe_popup"});
          });
    </script>
    
    <a href="#" class="open_popup">Click here to open the popup</a>
    
    <div style='display:none'>
    <div id='subscribe_popup' style='padding:10px;'> 
    <!-- BEGIN #subs-container --> 
    <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('subscribe')->toHtml() ?>
    <div id="subs-container" class="clearfix"> </div>
    </div>
    </div>
    <!-- END subscribe popup-->