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

时间:2015-02-06 15:33:46

标签: magento magento-1.6

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

我发现了一些不起作用的方法,最接近的是Mage::app()->getFrontController()->getRequest()->getRouteName(),它没有提供坚实的方法来检查我是否在“我的帐户”部分。< / p>

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

2 个答案:

答案 0 :(得分: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>

使用您想要的数据创建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")
{

}?>

答案 1 :(得分:0)

试试这个:

在布局页面

<customer_account_index translate="label">
    <label>Custom Page</label>
        <reference name="header">
        <block type="page/header" name="header">
            <action method="setTemplate"><template>your_custom_header_template_path/yourcustomheader.phtml</template></action>
        </block>
    </reference>
    <!-- Mage_Customer -->
    <update handle="customer_account"/>
</customer_account_index>

参考链接:

http://www.atwix.com/magento/how-to-change-the-header-of-magento-cms-page/

http://istockphp.com/magento/adding-custom-page-to-the-customer-account-dashboard/

相关问题