2013-02-04 143 views
0

我已經在目錄產品下創建了一個自定義選項卡,該選項卡會很好,但是當我單擊該選項卡時,該塊的模板未加載。它回顯我輸入的內容,但它不提取模板。我寫這個功能的一類HTC_Csvpricing_Block_Adminhtml_Catalog_Product_Tab擴展Mage_Adminhtml_Block_Template實現Mage_Adminhtml_Block_Widget_Tab_InterfaceMagento目錄產品中的管理自定義選項卡

public function _construct() 
{ 
    parent::_construct(); 
    echo "I m here"; 
    $this->setTemplate('csvpricing/tab.phtml'); 
} 

這裏就是我在寫的應用程序/設計/ adminhtml /默認/缺省/佈局/ csvpricing.xml

<csvpricing_adminhtml_csvpricing_index> 
    <reference name="content"> 
     <block type="csvpricing/adminhtml_csvpricing" name="csvpricing" /> 
    </reference> 
</csvpricing_adminhtml_csvpricing_index> 

<adminhtml_catalog_product_edit> 
    <reference name="product_tabs"> 
     <action method="addTab"> 
      <name>csvpricing_tab</name> 
      <block>csvpricing/adminhtml_catalog_product_tab</block> 
     </action> 
    </reference> 
</adminhtml_catalog_product_edit> 

請指導我什麼我錯過了。

感謝

+0

還當我檢查元素我得到這個消息那裏「此標籤包含無效數據,請在保存前解決問題。」 –

+0

你能告訴我們你的模板文件嗎? – dagfr

+0

@dagfr模板文件我只有[code] <?php echo「Test」?> –

回答

0

你可以做如下: 模塊的config.xml

<config> 
    <adminhtml> 
     <layout> 
      <updates> 
       <your_module> 
        <file>your-module.xml</file> 
       </your_module> 
      </updates> 
     </layout> 
    </adminhtml> 
</config> 

創建/app/design/adminhtml/default/default/layout/your-module.xml佈局XML :

<?xml version="1.0"?> 
<layout> 
    <adminhtml_catalog_product_edit> 
     <reference name="product_tabs"> 
      <action method="addTab"> 
       <name>your_module_some_tab</name> 
       <block>your_module/adminhtml_catalog_product_tab</block> 
      </action> 
     </reference> 
    </adminhtml_catalog_product_edit> 
</layout> 

創建{your_module} /Block/Adminhtml/Catalog/Product/Tab.php的標籤塊:

class Your_Module_Block_Adminhtml_Catalog_Product_Tab 
    extends Mage_Adminhtml_Block_Template 
    implements Mage_Adminhtml_Block_Widget_Tab_Interface 
{ 
    /** 
    * Set the template for the block 
    */ 
    public function _construct() 
    { 
     parent::_construct(); 

     $this->setTemplate('catalog/product/tab/some-tab.phtml'); 
    } 

    /** 
    * Retrieve the label used for the tab relating to this block 
    * 
    * @return string 
    */ 
    public function getTabLabel() 
    { 
     return $this->__('Some Tab'); 
    } 

    /** 
    * Retrieve the title used by this tab 
    * 
    * @return string 
    */ 
    public function getTabTitle() 
    { 
     return $this->__('Some Tab'); 
    } 

    /** 
    * Determines whether to display the tab 
    * Add logic here to decide whether you want the tab to display 
    * 
    * @return bool 
    */ 
    public function canShowTab() 
    { 
     return true; 
    } 

    /** 
    * Stops the tab being hidden 
    * 
    * @return bool 
    */ 
    public function isHidden() 
    { 
     return false; 
    } 
} 

如果你的模塊還沒有,你需要創建一個數據幫助器來支持翻譯。

請在/app/design/adminhtml/default/default/template/catalog/product/tab/some-tab.phtml標籤模板:

<div class="entry-edit"> 
    <div class="entry-edit-head"> 
     <h4>Some Heading</h4> 
    </div> 
    <div class="fieldset fieldset-wide"> 
     <div class="hor-scroll"> 
      <!-- your content here --> 
     </div> 
    </div> 
</div> 
+0

我按照你的指示,它只是顯示我的標籤在我的情況,但它沒有加載標籤數據點擊時:( –

+0

檢查錯誤日誌有一定是你輸入錯誤的XML或東西? – Meabed

+0

請檢查此圖片:http://www.4shared.com/photo/20-KD_Lf/csv_pricing.html –

相關問題