Magento新闻简报弹出窗口(模态窗口)在每个页面上开火。它应该只在主页上弹出

时间:2015-01-27 17:54:57

标签: javascript php jquery magento popup

我一直有这个持续存在的问题,我的时事通讯模式窗口弹出窗口在网站上的每个页面上都会启动。它非常具有侵入性,我希望它只在用户访问主页时弹出。我正在运行EE Magento ver。 1.13.1.0

我尝试过的代码如下,它放在footer.phtml中:

<?php if(Mage::getSingleton('cms/page')->getPageId() == '2' && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms') : ?>    

<div id="newsletter_sign_up" style="display:none;" >

<div style="padding:20px;" >
<form action="<?php echo($this->getUrl('newsletter/subscriber/new')) ?>" method="post" >
  <div class="fieldset">

    <h1 style="color: #28ced7; text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 28px;">verbiage goes here</h1>

    <h2 class="legend" style="text-align:left; font-family: Arial, Helvetica, sans-serif; font-size: 13px;">verbiage goes here</h2>
    <!--end-->
    <ul class="form-list">
      <li class="fields">
        <div class="customer-name">
          <div class="field name-firstname">
            <label class="required" for="firstname" style="text-align:left;"><em>*</em>First Name</label>
            <div class="input-box">
              <input type="text" class="input-text required-entry" maxlength="255" title="First Name" value="" name="firstname" id="firstname" autocomplete="off"/>
            </div>
          </div>
          <div class="field name-lastname">
            <label class="required" for="lastname" style="text-align:left;"><em>*</em>Last Name</label>
            <div class="input-box">
              <input type="text" class="input-text required-entry" maxlength="255" title="Last Name" value="" name="lastname" id="lastname" autocomplete="off"/>
            </div>
          </div>
        </div>
      </li>
      <li>
        <label class="required" for="email_address"  style="text-align:left;"><em>*</em>Email Address</label>
        <div class="input-box">

          <input type="text" class="input-text validate-email required-entry" title="Email Address" value="" id="email_address" name="email" autocomplete="off"/>

      <input class="pop_newsletter_source" name="source" type="hidden" value="3" />

        </div>
      </li>
    </ul>
  </div>
  <div class="buttons-set form-buttons">
    <button onclick="pop_newsletter.submit(); return false;" title="Submit" class="button" type="submit" autocomplete="off" style="position: relative; right: 140px;"><span><span>Submit</span></span></button>
  </div>
  <p class="required">* Required Fields</p>

  <h2 style="text-align: left; font-size: 10px;">Email Privacy Statement:</h2>
  <p style="font-family: Arial, Helvetica, sans-serif; font-size: 10px; text-align: left;">more verbiage</p>
  <!--//end-->
</form>
</div>

</div>

<?php endif; ?>

我已检查过验证页面ID是否为2。

<?php echo "<pre>"; print_r(Mage::getSingleton('cms/page')->getPageId()); echo "</pre>"; ?>

此外,我在堆栈上找到了这个代码片段,但无济于事,它也无法正常工作。

<?php if(Mage::getSingleton('cms/page')->getIdentifier() == 'home' && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms') : ?>

如果我发布JS有帮助那么我也会这样做。任何帮助将不胜感激。谢谢。

1 个答案:

答案 0 :(得分:0)

您的代码是放在页眉还是页脚中,并在每个页面上缓存?