我的本地主机上的代码与实时服务器上的代码完全相同,但它只能在本地主机上运行。
<?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
<?php echo "<pre>"; print_r(Mage::getBlockSingleton('page/html_header')->getIsHomePage()); echo "</pre>"; ?>它给了我一个“1”。
此外,我还尝试过:
if(Mage::getSingleton('cms/page')->getPageId() == '2' && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms')当我print_r的时候,它告诉我我的页面it是2。我很困惑。老实说,我没有更多的信息或代码可以提供或扩展。
发布于 2014-10-03 12:02:24
Rad试试这个
<?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键是标识符
https://stackoverflow.com/questions/26169815
复制相似问题