Magento - 如何判断我是否在"我的帐户"页面?

Mar*_*kie 3 magento magento-1.6

我想在Magento网站的页面顶部添加一些内容,但前提是客户位于"我的帐户"部分.我将把它添加到/app/design/frontend/xxxx/xxxx/template/page/html/header.phtml.如何检测客户是否在"我的帐户"部分?

我发现了一些不起作用的方法,最接近的方法Mage::app()->getFrontController()->getRequest()->getRouteName(),它没有提供一种坚如磐石的方式来检查我是否在"我的帐户"部分.

这些页面都有<update handle="customer_account" />XML,有没有办法获得当前页面的句柄?

Cla*_*nga 5

magento的做法是编辑你的local.xml文件.

你应该使用这样的customer_account_index句柄:

<customer_account_index>
  <reference name="header">
    <block type="core/template" name="new_customer_data" template="page/html/customer.phtml"/>
  </reference>
</customer_account_index>
Run Code Online (Sandbox Code Playgroud)

page/html/customer.phtml使用您想要的数据创建.

template/page/html/header.phtml<?php echo $this->getChildHtml('new_customer_data') ?>

另一种方式是:

<?php $action = Mage::app()->getFrontController()->getAction();
echo $action->getFullActionName('_');
if($action->getFullActionName('_')=="customer_account_index")
{

}?>
Run Code Online (Sandbox Code Playgroud)