有时候项目的须要,咱们可能会在后台中添加tabs,如今给product edit页面添加一个tabsphp
方法1:
按照下面的路径找到tabs.phphtml
找到这个类中的方法_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); }