magento 添加产品上传附件(中1)

承接上篇,我们开始控制器的开发

前端index控制器

app\code\local\Iverve\Uploadpdf\controllers
app\code\local\Iverve\Uploadpdf\controllers\IndexController.php
class Iverve_Uploadpdf_IndexController extends Mage_Core_Controller_Front_Action
{
	public function indexAction()
	{
		$this->loadLayout()->renderLayout();
	}
}

后端编辑控制器

app\code\local\Iverve\Uploadpdf\controllers\Adminhtml
app\code\local\Iverve\Uploadpdf\controllers\Adminhtml\UploadpdfController.php
class Iverve_Uploadpdf_Adminhtml_UploadpdfController extends Mage_Adminhtml_Controller_Action
{
protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('system/config/uploadpdf');
}

protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('uploadpdf')
->_addBreadcrumb(Mage::helper('adminhtml')->__('Add uploadpdf Category Management'), Mage::helper('adminhtml')->__('Add uploadpdf category Management'));

return $this;
}

public function indexAction() 
{
$this->_initAction()->renderLayout();
}


public function editAction(){
$id     = $this->getRequest()->getParam('id');
$model  = Mage::getModel('uploadpdf/uploadpdf')->load($id);

if ($model->getId() || $id == 0)
{
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
if (!empty($data))
{
$model->setData($data);
}
Mage::register('uploadpdf_data', $model);
$this->loadLayout();
$this->_setActiveMenu('uploadpdf');

$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Add uploadpdf Management'), Mage::helper('adminhtml')->__('Add uploadpdf Management'));
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Rule News'), Mage::helper('adminhtml')->__('Rule News'));

$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);

$this->_addContent($this->getLayout()->createBlock('uploadpdf/adminhtml_uploadpdf_edit'))
->_addLeft($this->getLayout()->createBlock('uploadpdf/adminhtml_uploadpdf_edit_tabs'));

$this->renderLayout();
}else{
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('uploadpdf')->__('Uploadpdf does not exist'));
$this->_redirect('*/*/');
}
}

public function newAction()
{
$this->_forward('edit');
}	
}

赞(1)
微信
支付宝
微信二维码图片

微信扫描二维码打赏

支付宝二维码图片

支付宝扫描二维码打赏

相关文章

Please Login to comment