【发布时间】:2017-02-15 16:38:45
【问题描述】:
我觉得这应该很简单,但我没有得到我想要的结果。我有一个显示在我所有网站上的电子邮件注册表单。如果他们碰巧使用商店代码ama_br 访问我的网站,电子邮件注册就会消失。这很好,而且有效。我的elseif 语句与显示在所有商店视图中的表单不同,我希望这个新表单仅在其商店代码ama_ca 时出现。它对我不起作用,我看不出我的代码有什么问题。请帮忙。谢谢。
<?php if (Mage::app()->getStore()->getCode() != "ama_br"):?>
<ul>
<li><?php echo $this->__('Email Sign Up')?></li>
<li>
<form action="<?php echo $this->getUrl('email_preferences')?>" method="get" id="newsletter-validate-detail">
<input name="email" type="text" id="newsletter" placeholder="<?php echo $this->__('Enter Email address')?>" title="<?php echo $this->__('Enter Email address')?>' class="required-entry validate-email">
<button class="submit">+</button>
<input type="hidden" name="source" value="nt">
</form>
</li>
<li class="footer-promo"><?php echo $this->getChildHtml('footer_promo')?></li>
</ul>
<?php elseif (Mage::app()->getStore()->getCode() == "ama_ca"):?>
<ul>
<li><?php echo $this->__('Email Sign Up')?></li>
<li>
<form method="post" action="http://enews.******.com/q/9MNK4U4iV9Mutb9YzTxF2zRWDIPgKoX0F0" accept-charset="UTF-8">
<input type="hidden" name="crvs" value="6hZNXcISD79ac2Empmsr2az_B3Qc5osTNmkOdNHleqhPIYmsxEOe6PbgaUo-3WBn_Vbgorrbk4qjekx7w4tljA">
<input type="hidden" name="CheckBox.Source.ca_footer" value="on">
<input name="email" type="text" id="newsletter" placeholder="Enter Email address" title="Enter Email address' class=" required-entry="">
<input type="hidden" id="submit" value="Sign Up">
</form>
</li>
<li class="footer-promo"><?php echo $this->getChildHtml('footer_promo')?></li>
</ul>
<?php endif;?>
【问题讨论】:
-
逻辑。只有一个
if块将执行。因为您在第一个测试中进行了!=测试,所以'ama_ca' != 'ama_br'为 TRUE,并且该块执行,完全跳过后面的== 'ama_ca'。 -
先检查
ama_ca。 -
@这个方法参考我的回答它会解决你的查询
-
谢谢@MarcB,我不知道这个逻辑是如何工作的。谢谢你。 *注明
标签: php html if-statement conditional