
寫好(hǎo)前台部分(fēn),現(xiàn)在要(yào↔×)做(zuò)的(de)就(jiù)是(shì≤€)要(yào)寫後台部分(fēn),配置文(wén)件(jiàn)在β∞↔前面已經提前寫出來(lái)了(le),但(dàn)還(☆♦§₹hái)需要(yào)說(shuō)明(míng)的(de)是(shα★$ì),後台部分(fēn)的(de)配置文(wén)件(≥"jiàn),在design/adminhtml/default/defau±ε₽★lt/layout/下(xià),還(hái)需多(duō)寫一(yī)個✔↑↑©(gè)配置文(wén)件(jiàn),count.xml&≈♦
<?xml version=&quλπ>ot;1.0"?><layout versi>₹π®on="0.1.0"> &α☆nbsp; <count_adminh✔γtml_count_index> &nbs≥®<p; &nγ→"bsp; π₹ ↑<reference name="conteφ♦nt"> &nb>©ε≥sp; &nβ® βbsp; <block > type="countε☆₩/adminhtml_count" name="$α ;count" /> ≈ & &n≥" ±bsp; <$∑</reference> &n₩↑←•bsp; </count_ad©≠★minhtml_count_index></layβ₩∑out>
貼圖看(kàn)下(xià)後台的(de)效±✔•果:
後台控制(zhì)器(qì)的(de)位置:
controllers/Adminhtml/CountControσ↕ller.php
<?phpclass Messagφ☆☆e_Count_Adminhtml_CountContro∑♠ller extends Mage_Adε§≥minhtml_Controller_actαεion{ pε≤rotected function&n∏↑bsp;_initAction() { &nb™♠<€sp; &nb δ★sp;$this->loadLayout()
©& &n©↓γbsp; &nbs¥♣£p; ->_∞δ₩setActiveMenu('count/items'ε;)
&nb&≠&sp;  ¥φ₽; ->_addBreadcrumb(Mage::he ♠εlper('adminhtml')-><☆★;__('Items λ♥Manager'), Mage::helper(• 'adminhtml')->__(>∏©≈'Item Manager'))&©©; &nb$α☆sp;
©αε  ₩₹β±; return $this;
 σ♦; } &nb★♠sp;
&n$βbsp; public functio≠≥n indexAction() {  ∞γ; &nbsπα☆≠p; $this->_initActio™¥n()
λ"☆♥ &♥ nbsp;  ∞♠↓£;->renderLayout();
&nλ εbsp; }♦♣λ &nbsαp;public function editAc<>←♠tion() {
≤ ¥€$id =Ω> $this->getRequest()-&g✘₩t;getParam('id');
&nbs♦✔λp; &nγ§bsp; $mod≈↕♣≤el = Mage::getModel(±✔39;count/count')->♥♣load($id); &nbs↓ ≠p; if ≤>;($model->getId() || $i☆÷d == 0)&nb§§εsp;{
&nbs∞Ω↓δp; &nb♥™£→sp; $→>₩§data = Mage::getSingleton(&£"≥↓#39;adminhtml/session')->g>"ΩetFormData(true); &nb∏§sp; &nb•₩↑&sp; &nb₽®₹↕sp;if (!empty($data&φ)) {
&nb&₽sp; &n" ★bsp; &ββnbsp; &nbsΩε≠p; $model->setData±↑($data);
&¥♥nbsp; &nb¶♣÷§sp; }
Ω< &↔©nbsp; &≈×αλnbsp;Mage::register('count_data'÷≥;, $model); &nbs∏♥₩₹p;  "≈×®; $tβ¶α≈his->loadLayout();&nb∑←σsp; &nb≈™sp;  ∑♦→; $this->_setAc>γ∞tiveMenu('count/i≠×₩®tems'); αΩ∑ &nbs©≠'p; $this->_€☆"πaddBreadcrumb(Mage::♦ε✔helper('adminhtml')->__(✘' 39;Item Manager'), Mag®®♠e::helper('adminhtml')->__≤¥<✘('Item Manag¥≤$er'));  ✔€✘; &nbσ÷®sp;  γ€₩;$this->_addBreadcrumb(∏★Mage::helper('adminhtml&↕φ#39;)->__('ItemΩ★ News'), Mage::hel♥♥↑per('adminhtml')->__♦<('Item News')); γ★ &n≥≠ε<bsp; &nbs♦>±p;$this->getLayout♦λ()->getBlock('head')-&g> t;setCanLoadExtJs(true); ≈§α  ₩$; &•≤nbsp; $this->&←;_addContent($this->getLayout()-✔&>createBlock('count/☆ •∞adminhtml_count_edit'↓;))
&nb©₹¶sp; ←✘ σ∑♥ ->_addLeft($this-™$♣€>getLayout()->createBlock('≤ ≈;count/adminhtml_coun☆ &t_edit_tabs')); &n↑±↑✘bsp; &nbs≥≠♥λp; &n©☆bsp; $this->renderLayout±¶();
&nb φsp; }&nbs€•♣p;else {
♦ &n§¥"bsp; Mage::getSingleton(λ≠¥'adminhtml/sessi ®∑on')->addError(Mage::↓εhelper('count')->__('I∑±§tem does not existφ₽39;)); &nb♦δ✘sp; &nbs$÷p; &nbs♥εp;$this->_redirect('*/*Ω±₽/');
 β✘$ ; &n¥ &bsp;}
 ←♣±♥;}
 ≤☆; public function newAc♥φtion() { &nbs'πα∏p; $thisφ≠↓->_forward('edit');
↕≈≤ } &®÷↕₹nbsp; //存儲數(shù)©✘≈&據
public ×≈δ;function saveAc÷Ω↑tion() { &•♥nbsp;  π¥; if ($data = &"¶;$this->getRequest()->ge'±tPost()) {
&nπ'✔×bsp; &nbs§✘p;  > λ ; $model = Mage≈₩ ::getModel('count/count∞σ39;); & ₹¥ nbsp;
>>§φ γ↑ &nbs☆εp; $model->setData($datλ≠Ω↓a)
&↕ δnbsp;  →;  ↓π; ->setId($t>&•↑his->getRequest()->ge©εε™tParam('id'));&nbsε♥≥p; &n≥α© bsp;  γ∑;
 ≈×; &n®πbsp;  Ω÷↕; try {&nbs☆"±<p; &nb©₩sp; &®∞nbsp;  ¶✘✘π; if ($model->getCrea∑↕tedTime == NULL || ↔¶$model->getUpdateTime() ==&n✔'&bsp;NULL) {
&n¶λΩbsp; ♥∞ ¥ &nbsφ≥β♣p; $model->setCreat←€↓₹edTime(now())
&nπ™ ✘bsp; &nb©≤sp; ₹>•α &nbsδ ¥βp; &€$λ★nbsp; ->setUpd±<ateTime(now());
&₹λnbsp; &n☆≤bsp; &nb →sp;  ↕ε;} else {
 ↕∑; &nbsδ∑p; &nbs♠©↑↑p; &>nbsp; $model->setUpdateTi₩₽✔me(now());
&n↔>∞§bsp;  ¶®; &nbλδ÷sp; ↑ ≠ } &σ✔↔nbsp;
&nb∑δsp; &n₹≥bsp;  γλ;
±₽ ♦≈• &n ∏&bsp; &σ<λnbsp; $model->♦σ≥;save();
 δ☆; &nbβ₩±sp; &n≥∑bsp;Mage::getSingleton('adminhtm≠φσl/session')->addSuccess(Mage::he←< lper('count')->__(λα♦9;Item was successfull×←♥σy saved'));
&nbs Ω→Ωp; ∑£ &α nbsp;Mage::getSingleton('∏¶σ&;adminhtml/session')-&g≥$t;setFormData(false); &nbs<ε↔p; &∞δ★nbsp; &nb♦ sp; i₽×Ωf ($this->getRequest()->'≤getParam('back')) •λ♥{ &nbs ♠♦αp; &nbs₽✘&p; &♣π↓nbsp; $t↕±♠←his->_redirect('*/*/edit←φ≈39;, array('id' ≈'=> $model->getId()));&"₩nbsp; &nb≠$sp;  ∞φ; &n™ εbsp;  $®≥; return;
&n≥£bsp;  €♠£₹; &¶↓ ₩nbsp; } &n÷£≤bsp; &nbsΩ p; &♣♥♠nbsp; $this->λπ>_redirect('*/*/'); &→→♥♥nbsp; &nb✘↓sp; &£γ return;
γ<∑ &nb¶sp; ₹ו™ }&nb±≥₽♥sp;catch (Exception $e)&nbs≥✔p;{
&nbsβ p;  ♠★; Mage: ∏:getSingleton('admi$×★♦nhtml/session')->aβ≥ →ddError($e->getMessage());
€&♦€  €γ; &★σ₹nbsp;  ®; Mage::getSingleton(£↓↓₩'adminhtml/session')->¶ >setFormData($dat→↔εa);  ☆≤≥♥; ™γ≥ &nb™ ×sp; $this->♦γ;_redirect('*/*/edit'£∏φ♠, array('id'≈↑; => $thi§→s->getRequest()->g¥ε∑etParam('id'))); &n☆≥★bsp; &nb♠★♣sp; &n¥↑☆$bsp; return;
¥↔∏
&nbs♣≠p; ♠♦ }
 ©≠∑; }
 ∞§; &nbs±&$ p; Mage::getSingleton(δ↓ $'adminhtml/session')->addErr&©or(Mage::helper('count')->__÷♥>('Unable to find&n♠♥$bsp;item to save'));ε  ©®→ ; $this->_redirec✘ →t('*/*/');
 γ↔♥; }
&nbs₹∏p; public function&∏®•®nbsp;deleteAction() { &€★nbsp; if(&♦₩×nbsp;$this->getRequest()->✘₩φ₩;getParam('id') β₽₩;> 0 )&&↔→nbsp;{ &nλ"bsp; &☆≈≤nbsp; try&n<✘ bsp;{
©δ &nb•"®sp; &nbsλ© πp; $model = £↕;Mage::getModel('count/count₩£✘9;);
&nb∞✘$←sp; &n≈π×bsp; ★♠£&
&n$§₩bsp;  λγ✘¥; &n✘δ bsp; &n♦γ≤bsp;$model->setId($this->getRequest()->getParam('i₽€±d'))
&nbsΩ×>→p; &nbs≠¶≤p;  >₩ ; α®§->delete();
 ♦±★♣;  "; &n×&$bsp; α←♦
™ ↓ ✘' β &n'✔<™bsp;Mage::getSingleton('admin₹ ©§html/session')->addSuc<©cess(Mage::helper('adminh↔®tml')->__('✔∏εεItem was su♣>"λccessfully deleted'));&n§"bsp; &n₽∑♠<bsp; &nbs>'p; &nb π←®sp; $this->_redirect(®÷©9;*/*/');
&n >bsp;  ¥§; } ♦♥catch (Exception $e) α©¶{
∞∞↕← &nb¶±♠sp; &n'↔bsp; Mage::getSiε¶≤♦ngleton('adminht¶β←ml/session')->addError($e->g♣♦₩etMessage());  &∞≥; &n↓↔≠bsp; &nb ™₽ sp;$this->_redirect(®φ∞∏9;*/*/edit', a¥₩rray('id' => $tα↔his->getRequest()->±≥;getParam('id')));
 '™×; &nbs≈Ω≤p; &nb♣← sp; }
&nbΩ¶sp; } &nb♠ ™sp; &♣ $this-&g≠↓±t;_redirect('*/*/');
 •∞; } >β↓ public function± ✘& massDeleteAction()&¥↕εnbsp;{
☆$ $we∞ΩbIds = $this-&¶$•gt;getRequest()->getPara β∞m('count'); &n →<≈bsp; ±♣δ€if(!is_array($webIds))&nbs♥↔p;{
&nb≠✔₽sp; Mage::getSin™>≤gleton('adminhtml/sessio λn')->addError(Mage::helpe∑β®±r('adminhtml')->__(←←®★39;Please select&n€≈♠∞bsp;item(s)'));
✘ € &n↑♣bsp;} else { &nb☆≤β©sp; &nb©®βsp; try&n↑★Ω✘bsp;{ ∏λ ✘'δ fo∞ ≥reach ($webIds as&n<Ω↕bsp;$webId) {
&π↔£nbsp; & ↓™nbsp; &¥±∑↕nbsp;  λ€¥; $¥→•count = Mage::getMode ±¥←l('count/countπ₹39;)->load($webId);
&nbs ∞§p; &♠★nbsp; &nb®↔sp; &nb® sp; $count->delete();
÷δ
&nbs ↕p; &nbs λp; &nbs¶→•♥p; }
&nb sp; α±α &nbs ¥₩p; Mage::getS≤Ω¥ingleton('adminhtml/session&÷<#39;)->addSuccess(
&n£&¶bsp;  ★≈≠✔; &nb♦¥¥'sp;  £'; ↓φ≥ Mage::helper('adminhtml'$∞;)->__( ™₹∑ &n∞εβbsp; &nα÷bsp;  ≈; ®♠ 'Total of %dα• record(s) were s∑← ☆uccessfully deleteσ→εγd', count($webIds)
&nbs↓✔p; ∑ π♦ &nb€•εsp; )
& ☆♦§nbsp; &nbε€∑≠sp; &δ∏'nbsp; );
'↓ ₹€  ♠↓;} catch (Exceptiφ÷σon $e) {
&nb≈sp;  Ω&δε;  ₽★; Mage::getSi®≠↓₽ngleton('adminhtml/session&γσσ#39;)->addError($e->get↔ Ω★Message());
&©≈α♥nbsp; &λ↓∏→nbsp; }
&nbγσ>sp; &≤£σnbsp; } &nbs>≥↕×p; &n σbsp; $this->_redirect('*/*✘®€₽/index');
&nbλ✔δsp;} &nbs $'↔p;
p↕€≥ublic function&nb•÷¶sp;massStatusAction()
&n∑γ÷bsp; {
&nbs→←↑≈p; → $webIds = $this↑✘®->getRequest()->getPa÷→ram('count');&€λ∑nbsp;  ↕←★ ; &nb sp;if(!is_array($webIds)) {±¶¶
&♣¶nbsp; &n¥✔bsp; Mage::getSingleton(®≠9;adminhtml/session')->addErr§σor($this->__('↔←&Please select itφ¥↑em(s)'));
&nbs↓♠p; &'≠₹nbsp;} else { &nbφ←πsp; ®↑÷↑ &nb✘£πsp; try { &nbs>ε←$p;  × ; &n₹≈≥↔bsp; fore₽≤ach ($webIds&nbs¥₽ p;as $webId) {
 σ; &nbs≠←↑p; ε$®  ₹φ; ®₽×α $count = Mage::getSing±★leton('count/count')
&nbs¥™↕p; ☆≥≈ &n✔≈♣™bsp; &nb€★sp; &n∏♣♠★bsp; ->load($webIdφ"↑)
&nbβ€sp; •₽∞ Ω¥♣÷ &nb÷€πsp;  ≥βγδ; ->setStatusεγ($this->getRequest()-≠Ω>getParam('stat§¶∏us'))
&nbs✘λ₹≤p; &n&≠bsp; &n♣≤bsp; &n ↑bsp; &nbs←>&p; ->setIsMas←£≠supdate(true)
&nb♣×✔↑sp; &•§ ↑nbsp; &α♣×nbsp; &n Ω✔bsp;  ∑♥; ->save();
♦©★ &nbs¶↑Ωφp; &™'≠nbsp; } ©↓α; &>™nbsp; &nbΩπ✘✘sp; $this-≤•">_getSession()->addSγ '©uccess( &↔®nbsp; &n≈¥→✔bsp;  ≥↑"; $this->__§ ε('Total of&n•★γδbsp;%d record(s) were ≈>¥successfully updated→β9;, count($webIds))
&nbs<<•p; &&♥nbsp; &nbs∞&×p; );
&n$>bsp;  ε£; }&nbs©Ω∑≥p;catch (Exception $e☆☆) { &nbs∏®<p; &n↔•☆bsp; ¥₽>δ $this->_getSes★∑>sion()->addError($e->getMessag↓•e());
α≠₽ ↑λ }
≠&✘× &nΩ↑'∞bsp; } &nbsσε•p; ₩✘☆♠$this->_redirect('*/*/index&♦♥#39;);
}♠αβ
}控制(zhì)器(qì)寫好(hǎo)之後₹,來(lái)看(kàn)看(kàn)後<♦台的(de)block文(wén)件(jiàn)夾怎麽寫,
Block |---Couβ∏nt.php |---Adminhtml α ≥β  'λ∞; |----Count.php &n×>§€bsp;  φ"β; |----Count &nbsλ p; &nbs§★σp; ©♥ |♦♥ ----Edit.php β™ &♦φ₽€nbsp;  ≥'© ; |---≤★-Grid.php &nb✘β •sp; &nbs•"£p;  α∞λ↓; |----Edit &nb✔∞γsp; &nbs¶>p; &nεσ§≠bsp;  ©¥; &n'±<↔bsp; |---Tabs.php &nb₹&sp; &∞₽λnbsp; &n>× bsp; &nbs§™p; | ¶✘---Form.php &nbs← πp; &nb©φ✔₹sp; &nbs§€δ×p; &✔≈nbsp; |--★>¥φ-Tab &n'bsp; ≠ ®ε &n>¥✘bsp; &σδ♠nbsp; &nb₹≈> sp; |---εσαForm.php
Block/Adminhtml/Count.php
<?phpclass Message_Count_Blockλε←_Adminhtml_Count extends&nbs♠ p;Mage_Adminhtml_Block_Widget_Grid_Contε♦ainer{ public φ ©function __construct☆®☆()
{ &n☆∏bsp; $this->_c' ontroller = £®'adminhtml_count';&n∞'β♥bsp; $this->₩ ;_blockGroup = 'count♠→→Ω'; &n✔Ω ₹bsp; $this->_heade®≠rText = Mage::helper('co★→✔¶unt')->__('Count&nb ≥ sp;Manager'); &nbs≥≤¶♣p; $this->_addButtonLabel&€≤↔÷nbsp;= Mage::helper(§≠39;count')->__(∏ 9;Add Item');  ≠↑≤; parent::__construct();€→
}
}Block/Adminhtml/Count/Grid.→¥php
<?php//此頁面控制(zhì)後台表單的(>₽de)信息輸出class Message_Count_λ♥Block_Adminhtml_Count_Gri∞≤βd extends Mage_Adminhtm•↓l_Block_Widget_Grid{ ©÷ public function __con↔$struct()
{&nbs"♥p;  γδ®; parent::__const •∑↔ruct();  £'♣; $this->setId♣&£('countGrid'); £∑× $t® ®his->setDefaultSort('count_♥>id'); &nb→≥€♥sp; $this->setDefault∏♣≥Dir('ASC'); &¶λ "nbsp; $this->setSa↑£≠veParametersInSession(true);
&←σ"€nbsp; } protect≤₩ed function&nbs£♦p;_prepareCollection()
&nbs₩ ♦εp; {
&nb☆₹↑sp; $collection✘↓₩ = Mage::getModel×"('count/count')->getColle§₽₽<ction(); &nb™★∏sp; $this->setCπ₹ €ollection($collection); &nbs≠♠εp; &nbs™✔p;return parent::_prepareCol™♦↑lection();
} &n☆←bsp;protected function _prepσ∑areColumns()
{ &¶λ≠"nbsp;  '•; $this->addCφσ®"olumn('count_id', ∞£β;array( &✘nbsp;   ×♥≈; 'header↑ε♦δ9; &n ∏•♣bsp;=> Mage::helper('countΩπ∞')->__('ID'),≥< &nbφ↑sp; &nb₽λsp; 'align' & ∞↓♦nbsp; =>&"δφ#39;right',  λ∞; &n£>bsp; //'↔♦width'  "÷≈☆; => '50p♣∑±x',
&δ£ nbsp; ÷≠39;index' &n α←bsp; => 'count±φ§_id',
&nbs φ≈∏p; )); &n↔₽βbsp; $this-&gγ✘' t;addColumn('Model_Name'™•₹∏, array( &nbs γp; &☆÷☆↕nbsp; 'headerα≈≤39; &nb↓€₩"sp;=> Mage::helper('cou∏≈σnt')->__('Model&nbsΩ∏αp;Name'), &n§<≤bsp; &nb ↑δ♣sp; 'align'  "§•; =>'le£"≠φft', &₽φ↓nbsp; &£≥→nbsp;'index' Ω&∞÷ => 'Model☆±α↓_Name',
&nb♠≤¥↑sp; )); &n≠≥ ®bsp;
&n→↕→bsp; &nbs ¥≠p;$this->addColumn('Name§→', array(&nbs₩™>§p; ×★§ &±Ω™λnbsp; 'header'&₹♠Ω$nbsp; =>δ₽; Mage::helper('cou≈₹$ nt')->__('♥'₩•;Name'), &nb ¶sp; &nβεΩbsp; '↕πalign' &↕₩>nbsp; =>'left', γ✘; &n≥σ↔✘bsp; &nbs>₩∑λp; 'in↕≥✘∏dex' ='∞π> 'Name',
&nbs÷€≥∏p; ✘ ₽ )); &nb ↓sp;   ≠¶;
&nb↔♠∏✔sp; $this-&g$¶t;addColumn('Serial_Number',§♥ array( &nb∞'sp; &nbsσ↕p; &nbs ≠p;'header' ®€∏ =>&nbs$ λp;Mage::helper('countα✘¥∑39;)->__('Seri×"al Number'), &$¶ ¶nbsp; ™<γ &nbs☆α p; 'align'&α↑nbsp; =&g±¶™∏t;'left', ®≠"; &nbs&≤αp; &nb₩ sp; 'index&'ε↓Ω#39; ↓₹ ₹ => 'Serial↑♠₽_Number',
&n←>bsp; &nbs↓♣♥p; )); &nbs₩♦₽p;
 ÷←✘↕; $this->addC÷§olumn('Email', array(&n ↕&&bsp;  ↑§; &nbs>p; 'hea↔•∞∑der' =∑≥σ> Mage::helper('count&δ↓#39;)->__('Email'),&nbs★•p; &n♣↓bsp; &αε≤>nbsp; ←Ω39;align'  ★∏; =>'left↔§γ 39;,  ≥♥; &nΩ∑bsp; &nbsβ≤£p; 'index'   >≠&; =>&&★nbsp;'Email',
& $ )); &§ ÷≥nbsp;
 π™; &nα> €bsp;$this->addColum∞Ω n('Date_Purchased',&nbs↓γ♠p;array( &nbs→§p; &n♥Ω←bsp; &nb≠"σsp;'header' ₹☆©&; => Mδ∏age::helper('count')->_↕÷_('Data Purchased'),&n®≠≠bsp; &n ∞bsp; &nbs♥<φp; 'ali♣→≤βgn' & α∑nbsp;=>'left', &nb±∞>sp; &γ≈' nbsp; &≥σ& ∞®♦α'index'  →©∞♣; => 'Date_Pu ₽☆rchased',
&n∑↔bsp; )); &nbs↕ p;
&n λ"→bsp; $this↑ ×§->addColumn('Messages_↕πδ₽Source', array(&nλ↔bsp; ε♥ €γ 'h✔÷♠₽eader' &nbs÷∑"p; =>&nbsδp;Mage::helper('count'÷ε;)->__('Messages SourceΩ∞9;), &> &©nbsp; &nbs↔$×p; 'a∏lign' &βΩ✘nbsp;=>'left', ≠∏≈ ♠÷ &nbs↔$±↑p; 'index'&n&÷bsp;  ₹✔↕σ; => 'Messages_Source&εβ₹ #39;,
 ♦β¥÷; ));  ∏¶↑;
&nλ♥¶bsp; &nbs β₩λp;$this->addColumn('Cont→✘±ent', array( &nb× 'sp; &nb↕$αsp; &nbs ≈✘p; 'header& ♦★#39; =&gβ§t; Mage::helper('count')÷σ->__('Content₹γ∑9;), &n♠βbsp; ↔$ &×¥±#39;align' &≈✔nbsp;=>'left'→♦, ☆$₹ &↓≈★€nbsp; 'index'&nbs↔≠♣ p; => $←39;Content',
&nbλ±sp; )); $$; &nbs®∏p; $this->addColumn('<₽<action', array(↔©δ® $δ∞ &nb'sp; ®↑≤♠'header' € α =>  ♦♣;Mage::helper('count')->__(☆Ω₩☆'Action'), &¶♦Ωnbsp; &nε↑☆bsp; π₽₹ 'width'&nbs≤±p; >&₹=> '100',&→✘¥ nbsp; &nb♥≤≠sp; &nbσ&sp; 'λ♣→;type'  ≥∞; => &¥♥∏♦#39;action', &nb→∑sp; &nbs¶δ∑☆p; σ★✘₹ 'getter'  ₽λ¥ ; =>&nb ™"sp;'getId', &n✔♠✔bsp;  ¥★≤; π < 'actions' ₹↑↓; => array(↔∞π↓ &nΩ¥bsp; ®δ' &nb✔φ♣∞sp; &n₩™₩bsp; array( &n<"bsp; &nb→₩≠↓sp; &nb'€↑sp; &nb•Ωsp; &nbs>§p; 'caption' &n≠∞↕®bsp; => ±₩;Mage::helper('cou"πnt')->__('Edit'πα;), &∏π≈$nbsp; &nb∞sp; &✘"$nbsp; &nbs♠p; &n♠♣bsp; 'url'&nbs£•p; &nbs >∑δp; => array(¶↕9;base'=>&nbsπ→©p;'*/*/edit'), → &nb≈©÷✔sp; &•☆→™nbsp; &n™•→¥bsp; &nγ¶♣bsp; ¶∑≈π 'field'&nπ₩bsp; =>•δ∏γ; 'id'
&n★∞bsp; &∞ε₽nbsp; &nbs≠£♠p; &n <¥₹bsp; &nb☆"sp;)
&nπβ↔♦bsp; &nbs<→>p; &n→λ∏¶bsp; ), &nbsσ¥p; &Ω↕γγnbsp; ×✘ ≥÷γφ 'filter'γ>×; => >→ ;false, &nbs✘™p; &n€Ω♣<bsp; &nbsλ&p; 'sortable' &nbs§•p;=> false, &n$Ωbsp; &nbsγ'p; ©♠ ®★↑♦9;index' ®§ → => 'stores&¶•♠<#39;, &nbε®'sp; &nb★✘∏₩sp;  ©ε<; 'is_syste§✘m' => true→₩'σ,
&nbs'≤§∞p; )); ∏≈; &nbs→∏p; &©♣¥'nbsp;
&nbsφδp; ret>"↓φurn parent::_prepareColumns();
&n> ↔bsp; } &₹±φ★nbsp; protected&nΩ¥bsp;function _prepareMassac★↑βtion()
{♦'  $€ ≤; $this-&gγ≥λt;setMassactionIdField(&☆δ★#39;count_id'); &nb≈•↑sp; &nbs★σp;$this->getMassactionBloc<®k()->setFormFieldName(&"•#39;count'); &nbs≤" p; ≈εγ"$this->getMassactio↑§nBlock()->addItem('delete™≥39;, array( &n¶₽bsp; &n>★←↑bsp; &n¶ &bsp;'label' &n↓€•bsp; => σφ;Mage::helper('count')->__&Ω&('Delete'),&nbλsp; &'®∞ nbsp; &n★§≈∏bsp; 'url' &nbs→δp; π£÷=> $this->getUr±∞l('*/*/massDelete'), &n•✘$≥bsp;  ★×$; ®✘ ↕¥9;confirm'  ♠ ♠;=> Mage::helper('count±λ±')->__('Are ∞δyou sure?')
←→ &nbs>↑£±p; )↕≠); &↓©nbsp; &n<♠bsp;return $this;
&nεα bsp; } φ↔; public function gΩε€etRowUrl($row)
{&nb★¥sp; ✔σreturn $this->getUrl('*/*↕♣α/edit', array('∞ ↕ ;id' =>&nbs φγp;$row->getId()));
&nbs→≤ε€p;}
}
Block/Adminhtml/Count/Edit.php
<?php//Grid表單頁面class Messa×∏•♣ge_Count_Block_Adminhtml_Co'π≈unt_Edit extend₽↑s Mage_Adminhtml≠↔_Block_Widget_Form_Container{&nb★₩ sp; puε↔¥blic function&nb←φsp;__construct()
&nb £$sp;{ &n↑γbsp; parent::_₽≈♦×_construct(); & ©φnbsp; &nb&$←sp;  γ♣↔•; &β✘δnbsp; ©≤
&× nbsp; $this->_objec₽↕₹→tId = 'id✘φ'; &nbβ÷£★sp; $this-&g≥₽>t;_blockGroup = '↔✔™∏count'; &nα∞'bsp; &nbsσ$p;$this->_controller&nΩ€σbsp;= 'admi →↑nhtml_count'; ✘δ★;  ₽€;
&nb≈≠sp; $thi≤§πs->_updateButton('save',&nb®∞∏sp;'label', Mage:♥∞β:helper('count')->÷≠;__('Save Item') ≠♠); ©♠ $this->_ ε'updateButton('delete', ★←;'label', Ma≥←ge::helper('count')->__(™♠'Delete Item'));&σ'∞ nbsp; &nb€<sp; &n↓$bsp;
 σ; $this-♠™←>_addButton('saveandcontinue>♣39;, array( &n™σαbsp;  ♥↔↕; 'label' '¶±; ×↑★₹=> Mage::helper('a'<♦dminhtml')->__('Save ¥ And Conti✘✘nue Edit'), &↓γ•nbsp; &nbs∏¥p; &nbs≈σp;'onclick' ∑™∏=> 'saveAndCon>∑↕tinueEdit()',&nb§÷sp; &n<✔bsp; &n¥♦♥bsp; 'class¶φ9; &nb ✔'&sp;=> 'saveλ'÷♥9;,
 πε↓β; &↑ >πnbsp;), -100); ±∞±∏; &n§↓∞bsp;$this->_formScripts ™♠™= "
&n∞ ∑✘bsp; ≥ $ &nbs p; function&n₹↑®∏bsp;toggleEditor() {
&n ®'bsp; &n¶≥bsp; &δ♠↕σnbsp; if σΩ<;(tinyMCE.getInstanceByI≥ d('count_content') ==&nbs$ε©p;null) {
&≥₩¥£nbsp;  "£; &nλ↓ ≠bsp; &nb"§sp; &nbsγ§☆∏p; tinyMCE.execCommand('mceA$♥₩ ddControl', ₹£←€false, 'count_content'÷∏↓;);
&n✔♥₽bsp; &β♣•∞nbsp; & ×≤nbsp; } else&nbs>$p;{
&nbsγ↕✔™p; &€£nbsp; &nb§©✔×sp; t≤™ ↕inyMCE.execCommand('₩∑α₽mceRemoveControl', false,&nb§§sp;'count_content');↕≥
&n©bsp; &n₹∏•bsp; ∑$&}
&nb→★©sp; &n$₽bsp; }
  Ω; &n₩€α≤bsp; f→αunction saveAndContin↕↔✘ueEdit(){
 ✘₩; &nb≤•₩sp; ★λ✔  £$; editForm.submi•♥t($('edit_form').action+'b₩♦ack/edit/');
→₽ &÷γnbsp; }
&nb✔↕♦sp; &nbs→♦¥¥p; ";
&$₹nbsp; }&n♣®bsp; public&nb≠™sp;function getHead₽ ↕erText()
 ®α≈; {  ≠©•α; if(&♠"♣nbsp;Mage::registry('count_data≤λ$$39;) && ✘↑Mage::registry('count_↓★data')->getId() )&n§¥bsp;{ &nb σ∞γsp; &&λ₽®nbsp; return "☆;Mage::helper('count'✘♣')->__("Edit&n✔ δσbsp;Item '%s↓$$39;", $this->β>htmlEscape(Mage::registry(&₹≈≥#39;count_data')->getTitl•ε¶₩e()));
&€ nbsp; } els≠¶♦e { &↓♦πnbsp; &π§ γnbsp; return&©♠≤÷nbsp;Mage::helper('count')-±"↕≠>__('Add Item'); ≠€
&εσ∞"nbsp; }
&nγ≈bsp; }
}Block/Adminhtml/Count/Edit♥>∞₽/Tabs.php
<?phpclass Mes₹γsage_Count_Block_Adminhtml_Count_Edit_δβ♠♦Tabs extends&nb∑←sp;Mage_Adminhtml_Block_Widget_Tabβ ×s{ public function&nbsσ₹↔λp;__construct()
{ &nb₩∏sp; ♠ ∑ parent::__constr♠€♦uct(); &nbσ™sp;$this->setId('count_tabs↕♠'); ₽ σ $this->setDe✘→stElementId('edit_form');&♣≤¥§nbsp; $'φ&this->setTitle(Mage::helpe≈₩r('count')->_φ§↕_('Item Information'©<₹));
} proteΩσcted function _beforeToHtm↕σΩ l()
{ &nb÷βsp; $this-₹ >addTab('form_section',&n₽£☆φbsp;array( &nb↑γ←sp; ✔☆'label' &♦♦≥nbsp; =€↔> Mage::helper('< ;count')->__('Item Info÷₽rmation'),   ®; &n & bsp; 'title'♠ ; =>&n≈®€•bsp;Mage::helper('count')φ♣->__('Item Informationγ♦↑'),  ↑≥; &nbs®→σ•p; 'content♦$<'39; =>&≠₹≤nbsp;$this->getLay♠λ®out()->createBlock('c≥≈ount/adminhtml_count_edi←•πt_tab_form')->toHtml(),
↕<
 ¶'☆;)); &nbs☆↑ p;
&nb$$sp; return parent≠' ::_beforeToHtml();
}
}€♣Block/Adminhtml/Count/Edit/Form.pπ≤hp
<?phpclass Message_Cou₽ ∑↑nt_Block_Adminhtml_Count_Edit_Form&n✔Ωπbsp;extends Mage_Adminhtml_Block_✘♠Widget_Form{ protected ✔≠→;function _prepareForm()
&n♣&bsp;{
&n♣ ₽εbsp;$form = new ≠®;Varien_Data_Form(array( ↕↔≤  →≈; &nbs&βp; &nbs<σ∏≠p; &nb←φsp; &nb÷'sp;  Ωεγ'; &n ♥¶bsp; 'id'&nαβ÷bsp;=> 'edit_form ↕♣∏39;,  ≥>₩; &φ↔nbsp; ∞♣ &nb₽$☆sp;  β"; &n★δ≤bsp; &♠®nbsp; β★ 'actionα↕' => $this->£&getUrl('*/*/save', array(&δ€#39;id' => $this-&g←t;getRequest()->getParam('Ω♠& ;id'))), &nbs≤☆←p; &n≈±bsp; &n÷•←bsp; &n∑£δbsp; &nbs✔& p; €φ &nbsΩ♥p; &nb∑>sp; &δ∞♣nbsp; 'method'&n≤φ€bsp;=> 'post', &nb< sp; &nb•£πsp; &nbs€∏≥p; &n₹™bsp;  ™>;  ★←; &nbs★≈¥p; €σ &£λnbsp; 'enctype' =&₽gt; 'multipart/form-data §39;
≠™ &n✔♣bsp; &n€✘♦↕bsp; &nb™♦sp; &nbs'₹≈p; &α≠nbsp; )
 π≠σ₹; &nσε£♦bsp; );
 £&; $form->setUseContaine÷π™¥r(true);  π≤; $this->setFo£←rm($form); ↑∑ return parent::_&≈prepareForm();
}
♠δ'
}Block/Adminhtml/Count/Edit/Tab/Form←β₹.php
<?php//這(zhè)個(gè)頁面是(sh★¥∞ì)控制(zhì)點開(kāi)列表進行(xíng)編輯的↕$↑(de)頁面class Message_Count_Block_Ad £ minhtml_Count_Edit_Tab_Form ¶♦ extends Mage_Admi♣✔nhtml_Block_Widget_Form{&nb<≤sp; protected function&nbs×¥♦♦p;_prepareForm()
&nbγ ±sp; {
&nbsπ ✔p; $form = new&nbsΩ✔p;Varien_Data_Form(); &nb "∞sp; §∏$this->setForm($f×♦Ωorm);
&n↑∑bsp; $fieldse↓↑t = $form->±≈∏&;addFieldset('cou¶₩¶&nt_form', arra₹π→εy('legend'=>Mage::helper(α 39;count')->__(≈♣'Item information')));
$↑→∑
&nbs<™✘p; ≈®$fieldset->addField('Model_Na♥↔↕me', 'text', a♠÷₹↓rray( &nb↓§♦↑sp; &nb←≥εsp; ' ↕;label'  γ¶λ≈; => M♦≥age::helper('count✘≠9;)->__('Model_Name'), &nb↑♦sp; &nbs♠®≈p; //σ≠♦↕ 'class'&n$←bsp; &≤₹nbsp;=> 'r£'≈equired-entry',
&→₹♥®nbsp; &nb↔φ•sp; &nbs©§¶p; 'requirπ™ €ed' => ∏<δ∑;true, &±→Ω←nbsp; &nbs≠€Ωp; & ≠£nbsp; 'nameε £ 39; &nbs∞♣$λp;=> 'Model_Naπ♠£>me',
&n₽∞&εbsp; ));
↔♣Ω± $fieφ®βφldset->addField('N <♦ame', 'text',&nb✘sp;array(  γ≥; &€♥nbsp; 'label∏γ&≥' &nbs★✘™p;=> Mage::helpe♠ r('count')-&↕φφ gt;__('Name'), &n≠®÷©bsp; &nb±♠±₩sp;  ¶™; // &♦≥#39;class' &nbε♠sp; => 're↔✔↕∑quired-entry',
&nbs≈λp;  ®↑;  '→÷; 'required' &nσ$λ'bsp;=> true, ×Ωβ &nbs≥±≠₽p; Ωβ39;name' & $♠<nbsp; =>&≥÷Ω→nbsp;'Name',
&nΩ↔bsp; ));
&nbsλβλp; &nb™ sp;$fieldset->addField('><Serial_Number', → ₽39;text', array( &÷§nbsp; &nγ€φbsp; §9;label' &≥★×§nbsp; => Mage::helper(α¶•α9;count')->__('Ser↔≈ial_Number'),&nbs&∏Ωp; ₽↔☆ &n♥¥bsp; // 'c©lass'  ≠×; => 'required-entry&± #39;,
&×₩nbsp;  σδ; &n∞±bsp;'required' &nbs™ p;=> true, ✘♦£♣  •↑×; &∑∞nbsp;  ↔® ≤;'name' &nb¶←φ♠sp; =&g♦&¥ t; 'Serial_Number&₩±φ#39;,
&nφ bsp;));
&nπ®πbsp; $fieldset->&✘addField('Email', <<;'text', array(&nbsφε™ p; &↓×nbsp; &nbs ✘★p; 'labelβ♥₹9; =&£≠<gt; Mage::helper('cφ©ount')->__('Email&¶£>#39;), 'σ☆  φ•™↔; //'£<♦class' &n↓γbsp;=> 'required-entry≠©9;,
&≈∞♦€nbsp; &nΩ₩₩σbsp; 'requi←₩red' => true,& σnbsp;  ☆π©→; ↑§♦ &nbsβ™♦₩p; 'name'&nbπ₹sp; =&♣↑•☆gt; 'Email',
€& ))÷↔;
 ↕÷£>; $fieldset->adα₽dField('Date_Purchase•☆d', 'text',&nbs←<p;array( &n↑♥♣bsp; &α$÷nbsp;  ✔€>'; σσδ→9;label' &∞£nbsp; => >×$₽Mage::helper('count<>"✘39;)->__('Date_Purchase↔βd'),  γ₽α; &nb÷$λ sp; //&nbs"✔₽πp;'class' &♦γ => '$&;required-entry'•,
&n€↕bsp; &n♣₽↑ bsp; '↑'§ required' => tru÷βe, &n×★σbsp; &nbs₩®φp; &nbs≈"p;'name' &nbs£¥←p; => '$"<Data_Purchased',
 $☆; ))σε;
&n±∏>bsp; $fieldset->addField(÷←<≤39;Messages_Source',&nbΩ™<≈sp;'select', array(&nφ✔✔bsp;  ₩★; &nb±$sp; ±↕'label' >×∑ => Mage::helper( ¥39;count')->__('Messages_ §♥Source'), &nb₩♦★sp; &nbs> p; &nb♦±¶αsp;//'class' &n¥•¶bsp; =>&" nbsp;'required-entry',
&n<∏αbsp; &nbsγδ<♣p; &≤©nbsp; 'reΩ↕↕quired' =>&nbs©↓₹$p;true, πΩ♣' &n•♣™×bsp; &™ ↔™#39;name' &nb¥σ'£sp; => 'Messa←£∑ges_Source',&nbs₹ ₹p; &nb♠★'✘sp;  ¥§; £♣39;values'  >♣✘; => array( &n"✔×<bsp; &nbs♥ §p; &n ®∑$bsp; &nbs>✔₹®p; &nb↕β ↓sp; array( &nb♦∏sp; &n₽®♠bsp; &γ₽₹>nbsp; &☆✘₹nbsp; &n★bsp; &nbsΩ∑p; ®σ¶'value' φ; =>&nb÷£φ✘sp;1, &nb&"sp; &nbφ♥∞sp; &↔×$∞nbsp; &α∏nbsp; &nb <>sp; &nbs ∑★p; 'label' &n₹←bsp; =>&nbsλp;Mage::helper('count')-&÷™gt;__('web Search'★ו),
&n§♠¥bsp; ↕✔   ¥; &n₽¥↔bsp; ), &'✘'nbsp; $α &nbs<→™p;
&nbΩΩ₽♥sp; &nb"★sp; &δ>¥nbsp; &nbα ♠<sp; array(&☆nbsp; &nbs<± p; &nbs✘↓p; &δ♦nbsp; &nbsδp; &nb→&sp; &nλλσbsp; 'value' &n≠←bsp; => 2,&nb"≈sp; βΩΩ &nb↕'ασsp; &nφ☆bsp; £≈> &n₩<≈λbsp; 'la$•bel' ↑'=> Mage::helper($¥§9;count')->__('Online&nb© sp;Review'),
&nb✘Ω↓↔sp; &n↕λ×>bsp;  φε; &n→£bsp; &nbsγ¶ ±p; ), & ↕nbsp; α$< &n≤₹™ bsp; &nb•<sp; array(&≠∏nbsp; &nbs↔γ$p; β↔ δ↓  α≈; π¶§β ↔≈ &nbs¶♦$♣p;'value'  ™'; => 3, &nbs♦ε✘p;   ₹; ≠≥•  ±♠φ; &nb↑σφsp; & ✔λnbsp; 'labe♣→↕l' =>✔±> Mage::help©β ≈er('count')->__('¶ Online Ad'),
&n€δ•bsp; &nbsε'p; ↑± &$¶→¶nbsp; &nbs₹↑∞p; ),   ✘₩; &nb↔§↔sp; ®σ™ &nbs£γp;  ♥→;array( &nbs&↔®p; &n↕ 'bsp; &nb✔↔∏©sp; ∑★  €≠; &n>↑£'bsp; 'value' →®✘; =>&nbs∑&εαp;4,  γσ ; &n•≈bsp;  β€; &n"¶bsp; &nb€™sp; 'label' &nελbsp; => Mage₩::helper('count')->__(σ9;Other'),
&nbφγ¥sp; &n∏σbsp; &nbσ∑>↑sp; &nb☆'€εsp; &n♠×bsp;),
☆© &nbs≤÷>p; ) ₽≤,
&∞÷nbsp; ));
 ♣ φ; $±✘™≠fieldset->addField('Con≠✘tent', 'text ≠', array(&nbs₹¥≤p; &₽nbsp;  • &π; 'label'&nb↔±sp; &nbβ₹sp;=> Mage::helper('count♠>$39;)->__('Conte☆✘nt'), β♦→ &nbs≈∏<≠p; &nbs™p; 'title'&nbsλεp; =>&nbsΩ♠&p;Mage::helper('count&>'#39;)->__('Content'), &€ &n↓'bsp; &nb♥∑π↑sp; •α9;class' £♦¥ =>λ≈λ♥; 'required-entrφ₽←γy', &nb&™sp; &nγ★λbsp; &n↑←bsp; 'required'↓ε β => true,  >✘££; &nbs→←p;  ₹<≤©; 'style'®¥δ ; &nb★ε§sp;=> 'width:278px; §→height:60px;', &nα←λbsp; ↑δ &n™$bsp; 'name'ε→' &n♣↔✔♣bsp;=> 'Content',&n≤♥←bsp; &n ÷bsp;  ®↕±; 'wysiwyg↕"¥>9; =>&nb™&sp;false,
 ≥σ÷$; ));  γδ;
&nb∏€sp;  >®↔;if ( Mage::getS₹©ingleton('adminhtml→§✘/session')->getcoun≤↑₩≤tData() )
&nb↕×δsp; {
©₹
&×₽£nbsp; &nb&€×πsp;$form->setValues(Mage::getSing★¥leton('adminhtml/session&¶ε♠✘#39;)->getcountData()✘");
&Ω∏¥nbsp; M"♦¶←age::getSingleton('adminhtml/sessiλΩon')->setcountData(null••∏↔);
&n€♦☆♦bsp; } elseif (&≈↕nbsp;Mage::registry('co£←→unt_data') ) {
&n♦♠σbsp; &γδnbsp; $form->setV£★₽alues(Mage::registry>('count_data')->β≥getData());
≥±★ } &nbs €φp; &nb∏±sp;return parent::ε✘_prepareForm();
∑±→}
}
