2013-04-28 5 views
0

빈 템플릿을 사용하여 다음 XML을 가진 사용자 지정 페이지를 만들려고합니다. 내 컨트롤러에서Magento 레이아웃 및 계층 형 탐색

, 나는

public function indexAction() 
{ 
     $this->loadLayout(); 
     $this->getLayout()->getBlock('root')->setTemplate('page/empty.phtml'); 
     $this->renderLayout(); 
} 

이 그리고 내 레이아웃에, 나는이 잘 작동하고 계층 탐색이 표시됩니다

<?xml version="1.0"?> 
<layout version="0.1.0"> 
    <brands_index_index> 
     <reference name="content"> 
      <block type="catalog/layer_view" name="catalog.leftnav" before="brands" template="catalog/layer/view.phtml"/> 
      <block type="core/template" name="brands" template="brands/brands.phtml" /> 
     </reference> 
    </brands_index_index> 
</layout> 

있습니다.

그러나 계층 적 탐색을 brands.phtml 템플릿 내에 표시하고 싶습니다. 따라서, 나는 다음을 수행하려고 :

<?xml version="1.0"?> 
<layout version="0.1.0"> 
    <brands_index_index> 
     <reference name="content"> 
      <block type="core/template" name="brands" template="brands/brands.phtml" > 
       <block type="catalog/layer_view" name="catalog.leftnav" as="catalog.leftnav" template="catalog/layer/view.phtml"/> 
      </block> 
     </reference> 
    </brands_index_index> 
</layout> 

그러나,이 내가 brands.phtml 내에서 ("catalog.leftnav") getChildHtml를 호출 할 때 작동하지 않습니다.

계층 형 탐색을 brands.phtml에서 호출해야하는 위치로 이동하려면 어떻게해야합니까?

"Magento Debug"의 "rendered blocks"섹션을 볼 때 블록이로드 된 것처럼 보입니다. 그러나 HTML이 생성되지 않습니다. 계층화 된 탐색이 왼쪽/내용/오른쪽 블록이나 다른 요소에 있어야한다는 규칙이 있습니까? getChildHtml 자신과 같은 속성이 아닌 자신의 이름 속성을 사용하여 어린이를 찾습니다

답변

0

감사합니다. 그래서 블록 정의를 변경하고 그에 따라 getChildHtml 호출을 변경하십시오.

<block type="catalog/layer_view" name="catalog.leftnav" as="mynav" template="catalog/layer/view.phtml" /> 
+0

이 역시 시도했습니다. 그것은 너무 일하지 않는다. : – henrybai

+0

FWIW, Magento 팀이 이름을 짓지 않고 동일한 가치를 지니고 있음을 알 수 있습니다 기술적 인 이유가 있는지 또는 단순한 문체 선택인지는 알 수 없습니다 – wierdo

+0

오, 레이어 모델을 가져와 그 setCurrentCategory 메서드를 호출하여 유용한 것을 얻을 필요가 있습니다. – wierdo

관련 문제