2012-02-08 2 views
1

홈 페이지에서 local.xml 파일의 two_column_right 템플릿을 사용하여 항목 표시를위한 4 열 그리드를 표시하려고합니다. 불행히도 다른 곳의 카탈로그 페이지에 대해 지정한 세 개의 열 그리드를 사용하고 있습니다./Magento 제품 홈 ​​페이지에 그리드 열 표시

아마 홈 페이지를 참조하는 태그 아래에 <update handle="four_column_grid" />을 삽입해야합니까 ??

<?xml version="1.0" encoding="UTF-8"?> 
<layout version="0.1.0"> 

<four_column_grid> 
    <reference name="product_list"> 
     <action method="setColumnCount"> 
      <count>4</count> 
     </action> 
    </reference> 
</four_column_grid> 

<three_column_grid> 
    <reference name="product_list"> 
     <action method="setColumnCount"> 
      <count>3</count> 
     </action> 
    </reference> 
</three_column_grid> 

<default> 

<!-- Header --> 
     <reference name="header"> 
      <action method="unsetChild"><name>welcome</name></action> 
     </reference> 


    <!-- Root --> 
    <reference name="root"> 
    <action method="unsetChild"><name>breadcrumbs</name></action> 
    </reference> 

    <reference name="footer">   
    <!-- Remove all the other Magento links - "Site Map, Search Terms, Advanced Search, and Contact Us" --> 
    <!-- <action method="unsetChild"><name>footer_links</name></action> --> 
    </reference> 

<!-- Right sidebar --> 
    <reference name="right"> 
    <remove name="paypal.partner.right.logo"/> 
    </reference> 

    </default> 


<catalog_category_default> 
    <update handle="three_column_grid" /> 
</catalog_category_default> 

<catalog_category_layered> 
    <update handle="three_column_grid" /> 
</catalog_category_layered> 

</layout> 
+0

목록 블록을 홈페이지에 어떻게 추가 하시겠습니까? – Vinai

+1

CMS에서 콘텐츠에 {{block type = "catalog/product_list"category_id = "51"template = "catalog/product/list.phtml"}}을 삽입했습니다. 1.3에서 1.4로 업그레이드하여 1.4 테마 프레임 워크에 맞게 모든 템플릿을 다시 만들었습니다. /이 호출은 1.3의 기존 코드입니다. – hotdiggity

답변

5

짧은 대답 : 레이아웃 XML을 사용하여 CMS 블록의 "내부"블록에 값을 설정할 수 없습니다.

액션 컨트롤러에서 loadLayout()을 호출하면 레이아웃 XML이 처리되고 모든 블록이 인스턴스화되고 <action> 노드가 실행됩니다. 그러나 블록은 아직 렌더링되지 않았습니다.
renderLayout()이 호출되면 블록은 toHtml() 메서드를 호출하여 렌더링됩니다.

블록이 인스턴스가 포함 된 cms/block (또는 cms/page) 인스턴스 일 경우이 블록이 현재 인스턴스화됩니다.

요청 흐름 중에 모든 레이아웃 XML <action> 노드가 이미 처리되었습니다.
본질적으로 아직 존재하지 않는 레이아웃 XML의 블록 인스턴스를 참조하고 있습니다.

해결 방법으로 레이아웃 XML을 사용하여 제품 목록 블록을 홈페이지에 추가 할 수 있습니다. 단점은 CMS 블록의 다른 콘텐츠에 자유롭게 배치 할 수 없다는 것입니다.

<cms_index_index><!-- layout handle for the default homepage action --> 
    <reference name="content"> 
     <block type="catalog/product_list" name="product_list"> 
      <action method="setTemplate"> 
       <template>catalog/product/list.phtml</template> 
      </action> 
      <action method="setCategoryId"> 
       <catId>51</catId> 
      </action> 
      <action method="setColumnCount"> 
       <count>4</count> 
      </action> 
     </block> 
    </reference> 
</cms_index_index> 

은 물론 당신은 제품 목록 블록에 한정되는 것은 아니다. 다른 콘텐츠 내부에 목록을 배치해야하는 경우 레이아웃 XML 광고를 사용하여 홈페이지에 CMS 블록을 추가 할 수 있습니다.

+0

고마워요! 완벽하게 작동합니다! :) – hotdiggity

0

rwd 테마를 확장 할 때 magento ce 1.9+에서 변경된 것 같습니다. 'name.after'와 'after'에 대해 더 많은 블록을 정의해야합니다.

<cms_index_index> 
    <reference name="content"> 
     <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml"> 
      <block type="core/text_list" name="product_list.name.after" as="name.after" /> 
      <block type="core/text_list" name="product_list.after" as="after" /> 
      <action method="setCategoryId"><catId>3</catId></action> 
      <action method="setColumnCount"><count>4</count></action> 
     </block> 
    </reference> 
</cms_index_index> 
관련 문제