我在本地主机上拥有与在实时服务器上完全相同的代码,但它仅适用于localhost。
<?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; ?>
当我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
它告诉我我的pageid是2.我很困惑。老实说,我没有更多的信息或代码可以提供或扩展。
答案 0 :(得分:0)
Rad公司 试试这个
<?php if(
Mage::getSingleton('cms/page')->getIdentifier() == 'home' &&
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'
) : ? >
//insert your code here
<?php endif; ?>
此处主页是您检查的主页网址管理员&gt; CMS&gt;网页&gt;选择您的主页,此处URL Key是标识符