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');
}	
}

相关文章

0 0 投票数
文章评分
订阅评论
提醒
0 评论
最旧
最新 最多投票
内联反馈
查看所有评论