2013-11-01 74 views
0

我想將我的註銷鏈接放在我的歡迎信息旁邊。歡迎信息旁邊的註銷鏈接

我試過,但沒有成功:

<span class="welcome-msg"><?php echo $this->getWelcome(); ?> 

<?php if (! Mage::getSingleton('customer/session')->isLoggedIn()):?> 
<?php echo Mage::helper('customer')->getLoginUrl(); ?> 
<?php endif; ?> 

</span> 

回答

0

開始通過固定你的php:

<span class="welcome-msg"><?php echo $this->getWelcome(); ?> 

      <?php if (! Mage::getSingleton('customer/session')->isLoggedIn()):?> 
      <?php echo 1; ?> 
      <?php echo Mage::helper('customer')->getLoginUrl(); ?> 
      <?php endif; ?> 

</span> 
+0

謝謝,但它不起作用。沒有錯誤消息,但註銷鏈接未顯示。也許我應該嘗試使用core \ Mage \ Page \ Block \ Html \ Header.php或者customer.xml? – capola

+0

然後,if語句爲false或getLoginUrl()不返回任何內容。在if語句之間加上一個額外的回聲(例如echo 1)以確認這一點。 – davey

+0

感謝您的建議!可以 - 編輯你的答案讓我理解正確嗎? – capola

0

確定,因此該解決方案是使用原始的頂部鏈接:

<div class="welcome-msg"><?php echo $this->getWelcome(), $this->getChildHtml('topLinks') ?> </div> 

之後,我不得不在customer.xml和checkout.xml中評論一些無用的行。請注意以下幾點非常重要:

<!--Load this update on every page when customer is logged in--> 

<customer_logged_in> 
    <reference name="top.links"> 
     <action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>100</position></action> 
    </reference> 
</customer_logged_in>