有時候項目的須要,咱們可能會在後臺中添加tabs,如今給product edit頁面添加一個tabs
php
方法1:
按照下面的路徑找到tabs.php
html
找到這個類中的方法_prepareLayout()
在下面加入代碼:ajax
$this->addTab('inventoryInfo', array( 'label' => Mage::helper('catalog')->__('批次/卷號/存庫'), 'url' => $this->getUrl('inventoryinfo/adminhtml_product/inventoryinfo', array('_current' => true)), 'class' => 'ajax', ));
新建模塊inventoryInfo,建立控制器inventoryinfo/adminhtml_product/inventoryinfothis
class Silk_Inventoryinfo_Adminhtml_ProductController extends Mage_Adminhtml_Controller_Action { public function inventoryInfoAction() { $this->loadLayout(); $block = $this->getLayout()->getBlock('admin.product.inventory'); $block ->setProductId($this->getRequest()->getParam('id')); $this->renderLayout(); } }
找到後臺的catalog.xml在裏面添加一下代碼:url
<!--產品卷號、批次--> <inventoryinfo_adminhtml_product_inventoryinfo> <block type="core/text_list" name="root" output="toHtml"> <block type="inventoryinfo/adminhtml_inventoryinfo" name="admin.product.inventory" /> </block> </inventoryinfo_adminhtml_product_inventoryinfo> <!--產品卷號、批次-->
block的建立inventoryinfo/adminhtml_inventoryinfospa
public function __construct() { $this->setTemplate();//phtml模板路徑 $this->setUseAjax(true); }