2013-02-04 139 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 –

相关问题