2015-02-06 23 views
3

고객이 내 계정 섹션에있는 경우에만 Magento 사이트의 페이지 상단에 뭔가를 추가하고 싶습니다. 나는 그것을 /app/design/frontend/xxxx/xxxx/template/page/html/header.phtml에 추가 할 것이다. 고객이 '내 계정'섹션에 있는지 어떻게 알 수 있습니까?Magento - "내 계정"페이지에 있는지 어떻게 알 수 있습니까?

나는 작동하지 않는 몇 가지 방법을 발견했습니다. 가장 가까운 것이 Mage::app()->getFrontController()->getRequest()->getRouteName()인데, 이는 "내 계정"섹션에 있는지 확고한 방법으로 확인하지 않습니다.

이 페이지는 모두 XML에서 <update handle="customer_account" />입니다. 현재 페이지의 핸들을 얻을 수있는 방법이 있습니까?

답변

4

당신의 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

감사합니다! 그게 정말 잘됐다. 약간 다르게했는데, ''대신 ''태그에'' 태그를 넣었습니다. 이는 "계정 대시 보드"가 아닌 모든 고객 계정 페이지에 업데이트를 적용 할 수 있다는 이점이있었습니다. 또한 고객 계정에 추가 한 일부 사용자 정의 메뉴에는''태그가 포함되어 있으므로이 태그에도 적용됩니다. 훌륭한 답변을 해주셔서 대단히 감사합니다! – Markie

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/