我剛開始學習magento.I在控制器中有一個數據列表。我想在我的視圖文件中顯示該列表。我怎樣才能做到這一點 ? 這是我的控制器操作類別。我在哪裏得到數據的數組。如何在magento的視圖文件中加載數據?
<?php
class Company_Web_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
public function addcategoryAction()
{
if ($this->getRequest()->isPost())
{
$data = $this->getRequest()->getParams();
$catName = $data['catName'];
$status = $data['status'];
$data = array('name'=>$catName,'status'=>$status);
$model = Mage::getModel('web/web')->setData($data);
try {
$insertId = $model->save()->getId();
$this->_redirect('web/index/category');
} catch (Exception $e){
echo $e->getMessage();
}
}
$this->loadLayout();
$this->renderLayout();
}
public function categoryAction()
{
$collection = Mage::getModel('web/web')->getCollection()->getData();
$this->loadLayout();
$this->renderLayout();
}
}
?>
謝謝夥計爲你提供幫助 – Nikul