2012-12-16 2 views
1

나는 단순히 활성화 된 경우 내 자신의 템플릿 파일과 파일 shipping.phtml/원래 카트를 오버라이드 (override) 할 것을 확장 구축을 위해 노력하고 작동하지 해제 활성화하면 확장 기능을 사용할 수 없습니다. 수동으로 내 레이아웃 블록 테마를 변경하면 확장 프로그램이 실제로 작동 함을 알 수 있습니다. 그러나, 나는 그것을하고 싶지 않다. 제 코드를 살펴보고 제가 잘못하고있는 것을 알려주시겠습니까? 나는 그것이 내 블록 파일과 관련이 있다고 가정하고있다. 추신 무엇이 잘못되었고 어떻게 수정해야하는지 알 수 있다면 확장 기능을 사용하는 경우 CSS 파일을 설정하는 방법을 알려줄 수 있습니까?사용자 정의 젠토 확장</p> <p>내가 클릭하면 .. 사용하고

여기에 내 모든 파일 :

등/config.xml에

<?xml version="1.0"?> 
<config>  
<modules> 
<Module_Name><version>1.0.0</version></Module_Name> 
</modules> 

<global> 
     <blocks> 
      <modulename> 
        <class>Module_Name_Block</class> 
      </modulename> 
     </blocks> 

<helpers> 
    <modulename> 
     <class>Module_Name_Helper</class> 
    </modulename> 
</helpers>  
</global> 


<modulename> 
<settings> 
<enable>1</enable> 
</settings> 
</modulename> 

<frontend> 
<layout> 
    <updates> 
     <modulename> 
      <file><!-- shipping.xml --></file> 
     </modulename> 
    </updates> 
</layout> 
<routers> 
    <modulename> 
     <use>standard</use> 
     <args> 
      <module>Module_Name</module> 
      <frontName>modulename</frontName> 
     </args> 
    </modulename> 
</routers> 
</frontend> 


<adminhtml> 
<acl> 
    <resources> 
     <admin> 
      <children> 
       <system> 
        <children> 
         <config> 
          <children> 
           <modulename> 
            <title>Shipping Extension</title> 
           </modulename> 
          </children> 
         </config> 
        </children> 
       </system> 
      </children> 
     </admin> 
    </resources> 
</acl> 
</adminhtml> 

</config> 

등/system.xml을

<?xml version="1.0"?> 
<config> 
<tabs> 
<module translate="label"> 
    <label>Custom Extensions</label> 
    <sort_order>100</sort_order> 
</module> 
</tabs> 

<sections> 
     <modulename translate="label"> 
    <label>Shipping</label> 
    <tab>module</tab> 
    <frontend_type>text</frontend_type> 
    <sort_order>1000</sort_order> 
    <show_in_default>1</show_in_default> 
    <show_in_website>1</show_in_website> 
    <show_in_store>1</show_in_store> 


     <groups>    

      <settings translate="label"> 
      <label>Settings</label> 
      <frontend_type>text</frontend_type> 
      <sort_order>1</sort_order> 
      <show_in_default>1</show_in_default> 
      <show_in_website>1</show_in_website> 
      <show_in_store>1</show_in_store> 

       <fields> 
        <enable translate="label"> 
        <label>Enable</label> 
        <comment> 
        <![CDATA[Enable or Disable this extension.]]> 
        </comment> 
        <frontend_type>select</frontend_type> 
        <source_model>adminhtml/system_config_source_yesno</source_model> 
        <sort_order>1</sort_order> 
        <show_in_default>1</show_in_default> 
        <show_in_website>1</show_in_website> 
        <show_in_store>1</show_in_store>      
        </enable>   
       </fields> 

      </settings> 
     </groups> 
    </modulename > 
</sections>  
</config> 

도우미/Data.php

<?php 
class Module_Name_Helper_Data extends Mage_Core_Helper_Abstract 
{ 

} 
있습니다

블록/장바구니/Shipping.php

<?php 

class Module_Name_Block_Cart_Shipping extends Mage_Checkout_Block_Cart_Shipping 
{ 
protected function _beforeToHtml() 
{ 
if(Mage::getStoreConfig('modulename/settings/enable')) 

$this->setTemplate('module/name/shipping.phtml'); 

return $this; 
} 

} 

답변

4

부울 구성 데이터를 확인하려면 Mage::getStoreConfigFlag() [link]을 사용하는 것이 더 적절합니다. 이 경우, 순전히 레이아웃 XML 없이없이 블록 클래스를 다시 작성해야하는 훅이 있습니다. 만큼 모듈도 <depends />로 구성되어 같은 Mage_Checkout에이 레이아웃 XML 업데이트가 병합됩니다

<?xml version="1.0"?> 
<layout> 
    <checkout_cart_index> 
     <action method="setTemplate" block="checkout.cart.shipping" ifconfig="dropdownshipping/settings/enable"> 
      <template>beckin/dropdownshipping/drop_down_shipping.phtml</template> 
     </action> 
     <action method="addCss" block="head" ifconfig="dropdownshipping/settings/enable"> 
      <template>css/beckin/dropdownshipping.css</template> 
     </action> 
    </checkout_cart_index> 
</layout> 

:

구성 모듈에 대한 사용자 정의 레이아웃 업데이트 파일 및 해당 파일에 단순히 다음을 수행 in을 사용하여 핵심 템플릿을 덮어 씁니다. 따라서 잠재적 인 충돌 레이아웃 XML 명령을 무시 - - 어떤이 있다고 가정하지

촬영 한 접근을하는 유일한 이유는 철저하게 템플릿이 직전 렌더링에 모듈의 템플릿에 설정됩니다 할 수 있다는 것입니다 캐시 히트, 논쟁의 여지가있는 행동.

+0

감사합니다. @benmarks! 그래서 내가 만든 배송 블록을 제거하고 이것을 etc/config.xml 파일이나 etc/config.xml 파일에서 주석 처리 한 것과 같은 template layout.xml 파일에 추가해야합니까? –

+0

당신은 남자입니다 !! 정말 고맙습니다! ifconfig = "dropdownshipping/settings/enable"을 추가하여 레이아웃을 제어 할 수 있는지 몰랐습니다. 너 락! 정말 고마워!! –

관련 문제