首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Magento if语句在live上不起作用,但在localhost上起作用

问Magento if语句在live上不起作用,但在localhost上起作用
EN

Stack Overflow用户
提问于 2014-10-03 05:17:53
回答 1查看 197关注 0票数 2

我的本地主机上的代码与实时服务器上的代码完全相同,但它只能在本地主机上运行。

代码语言:javascript
复制
<?php if(Mage::getBlockSingleton('page/html_header')->getIsHomePage()) : echo "<div id='newsletter_sign_up' style='display:none;' >

<div style='padding:20px;' >
<form action=".$this->getUrl('newsletter/subscriber/new')." method='post' >
  <div class='fieldset'>
    <!--update on Sep16, for merge Tim work for newsleeter
    //start
    //<h2 class='legend'>Newsletter Sign-up</h2>
    -->
    <h1 style='color: #28ced7; text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 28px;'>Science and Beauty News + Special Promotions!</h1>

    <h2 class='legend' style='text-align:left; font-family: Arial, Helvetica, sans-serif; font-size: 13px;'>Sign up for our e-Newsletters and take advantage of special offers, promotions, contests and other exciting news. We average just two emails a month and you can opt out at any time. We respect and protect the privacy of our customers and those who use our website.</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>
  <!--//merge Tim work for newsletter-->
  <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;'>We will not share, sell, rent, swap or authorize any third party to use your e-mail address. If you no longer wish to receive e-news, follow the 'unsubscribe' instructions located near the bottom of each newsletter</p>
  <!--//end-->
</form>"; ?>


</div></div>    
<?php endif; ?> 

When I print_r

代码语言:javascript
复制
<?php echo "<pre>"; print_r(Mage::getBlockSingleton('page/html_header')->getIsHomePage()); echo "</pre>"; ?>

它给了我一个“1”。

此外,我还尝试过:

代码语言:javascript
复制
if(Mage::getSingleton('cms/page')->getPageId() == '2' && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms')

当我print_r的时候,它告诉我我的页面it是2。我很困惑。老实说,我没有更多的信息或代码可以提供或扩展。

EN

回答 1

Stack Overflow用户

发布于 2014-10-03 12:02:24

Rad试试这个

代码语言:javascript
复制
<?php if(
Mage::getSingleton('cms/page')->getIdentifier() == 'home'  &&
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' 
) : ? >

//insert your code here 

<?php endif; ?>

这里的主页是您的主页url,用于检查goto Admin>CMS>pages>选择您的主页,此处的URL键是标识符

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26169815

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档