如果客户已登录/未登录Magento,则显示/隐藏数据
我需要显示和隐藏一个表单,即客户是否登录 我有一个助手:如果客户已登录/未登录Magento,则显示/隐藏数据,magento,helper,Magento,Helper,我需要显示和隐藏一个表单,即客户是否登录 我有一个助手: <?php if ($this->helper('customer')->isLoggedIn() ) { echo "Hide Form"; } else { echo "<form id="form1" name="form1" method="post" action="post.php"> <input name="Type your na
<?php
if ($this->helper('customer')->isLoggedIn() ) {
echo "Hide Form";
} else {
echo "<form id="form1" name="form1" method="post" action="post.php">
<input name="Type your name" type="text" value="name" />
<label>
<input type="submit" name="send" id="send" value="Submit" />
</label>
</form>";
}
?>
谢谢
我的猜测是,你的问题来自于你所回应的html中的引号。Php将该块视为echo”我已经在review file.phtml中尝试了这个选项
<script type="text/javascript">
function hideshow(which){
if (!document.getElementById)
return
if (which.style.display=="block")
which.style.display="none"
else
which.style.display="block"
}
</script>
<?php
if ($this->helper('customer')->isLoggedIn() ) {
$showHide = "style=display:none";
} else {
$showHide = "style=display:block";
}?>
<?php if(Mage::helper('oscheckout')->isCouponActive()):?>
<div class="fivecol" id="coupon-container">
<?php echo $this->getChildHtml('coupon') ?>
</div>
函数隐藏(which){
如果(!document.getElementById)
返回
if(哪个.style.display==“块”)
which.style.display=“无”
其他的
which.style.display=“block”
}
谢谢分配,这真的很好。很高兴!如果答案对您有帮助,请将其标记为已接受。仅仅通过显示隐藏表单不是一个好方法:对于已注销的用户无。像我这样的人可以检查元素并使表单可见。我同意@rajatsaurastri-根据OP的建议,如果用户未登录,则不应生成表单例如,如果表单需要登录用户的ID,则也可能导致错误。
<script type="text/javascript">
function hideshow(which){
if (!document.getElementById)
return
if (which.style.display=="block")
which.style.display="none"
else
which.style.display="block"
}
</script>
<?php
if ($this->helper('customer')->isLoggedIn() ) {
$showHide = "style=display:none";
} else {
$showHide = "style=display:block";
}?>
<?php if(Mage::helper('oscheckout')->isCouponActive()):?>
<div class="fivecol" id="coupon-container">
<?php echo $this->getChildHtml('coupon') ?>
</div>