1.先创建后台menu

config.xml<?xml version="1.0"?><config><modules><Www_Employee><version>0.1.0</version></Www_Employee></modules><global><models><employee><class>Www_Employee_Model</class><resourceModel>employee_mysql4</resourceModel></employee><employee_mysql4><class>Www_Employee_Model_Resource</class><entities><web><table>web</table></web></entities></employee_mysql4></models><blocks><employee><class>Www_Employee_Block</class></employee></blocks><helpers><employee><class>Www_Employee_Helper</class></employee></helpers><resources><employee_read><connection><use>default_read</use></connection></employee_read><employee_write><connection><use>default_write</use></connection></employee_write><employee_setup><setup><module>Www_Employee</module><class>Www_Employee_Model_Resource_Setup</class></setup></employee_setup></resources></global><admin><routers><adminhtml><args><modules><Www_Employee after="Mage_Adminhtml">Www_Employee</Www_Employee></modules></args></adminhtml></routers></admin><frontend><routers><employee><use>standard</use><args><module>Www_Employee</module><frontName>employee</frontName></args></employee></routers></frontend><adminhtml><layout><updates><employee>employee.xml</employee></updates></layout></adminhtml>
</config>
adminhtml.xml<?xml version="1.0"?><config><menu><employee translate="title" module="employee"><title>Employee</title><sort_order>999</sort_order><children><items translate="title" module="employee"><title>Manage Employees</title><sort_order>0</sort_order><action>adminhtml/adminhtml_employee</action></items></children></employee></menu><acl><resources><admin><children><employee><title>Www_Employee</title><sort_order>10</sort_order></employee></children></admin></resources></acl><layout><updates><employee><file>employee.xml</file></employee></updates></layout>
</config>

创建后台 controller

<?phpclass Www_Employee_Adminhtml_EmployeeController extends Mage_Adminhtml_Controller_Action
{public function indexAction(){$this->loadLayout();$this->_addContent($this->getLayout()->createBlock('employee/adminhtml_employee'));$this->renderLayout();}
}

创建后台布局文件

<?xml version="1.0"?><layout><employee_adminhtml_employee_index><reference name="content"><block type="employee/adminhtml_employee" name="employee"/></reference></employee_adminhtml_employee_index>
</layout>


2. 创建 grid container

<?php
/** 像是一个容器,包含着 Grid 表*/class Www_Employee_Block_Adminhtml_Employee extends Mage_Adminhtml_Block_Widget_Grid_Container
{public function __construct(){$this->_blockGroup = 'employee';$this->_controller = 'adminhtml_employee';$this->_headerText = Mage::helper('employee')->__('Employee Manager');$this->_addButtonLabel = Mage::helper('employee')->__('Add Employee');parent::__construct();}
}



3. 创建 grid

关于这个 _prepareCollection() 方法, 不会令人疑惑,只是返回并set该模块的集合,这就是你所要展现在 Grid 表中的具体数据内容接下来我们要看的就是 _prepareColumns() 方法,这里我们会为我们的 Grid 表添加列:$this->addColumn('id', array('header'    =>    Mage::helper('employee')->__('ID'),'align'     =>     'right','width'     =>     '10px','index'     =>     'id',
));'id'         ==>   是列的唯一 ID 号,div 的 id
'header'     ==>   是列显示的名称
'index'      ==>   是来自于我们 Collection 中的一个字段,这个“id”列是存在于我们 Collection 的模块中。
<?phpclass Www_Employee_Block_Adminhtml_Employee_Grid extends Mage_Adminhtml_Block_Widget_Grid
{public function __construct(){parent::__construct();$this->setId('employeeGrid'); //在这里 setId 的值为 HTML 代码中的 <div> 标签中 ID 的值,当你在同一个页面中应用多个Grid表时,ID 的值必须是唯一的$this->setDefaultSort('web_id');  // 这个setDefaultSort 的值在 grid 表中用来说明用哪个列来排序,并告诉 Magento 用哪一个列来作为默认排序$this->setDefaultDir('ASC'); //  默认的排序顺序,ASC(正序)或 DESC(倒序)$this->setSaveParametersInSession(true); //这个设置用来保存你在 Grid 表中所做的操作到 Session 中,//比如说你在 Grid 表分页中的第2页或做了一些搜索筛选操作,//当你刷新页面或返回到该页面时,你刚所做的操作依然存在,//页面不会返回到初始值或状态}protected function _prepareCollection(){$collection = Mage::getModel('employee/web')->getCollection();$this->setCollection($collection);return parent::_prepareCollection();}protected function _prepareColumns(){$this->addColumn('web_id', array('header' => Mage::helper('employee')->__('ID'),'align' =>'right','width' => '50px','index' => 'web_id',));$this->addColumn('title', array('header' => Mage::helper('employee')->__('Title'),'align' =>'left','index' => 'title',));$this->addColumn('content', array('header'    =>   Mage::helper('employee')->__('Description'),'width'     =>   '150px','index'     =>   'content',));return parent::_prepareColumns();}
}

记得创建 model 创建表

<?php
$installer = $this;
$installer->startSetup();
$installer->run("-- DROP TABLE IF EXISTS {$this->getTable('employee/web')};
CREATE TABLE {$this->getTable('employee/web')} (
`web_id` int(11) unsigned NOT NULL auto_increment,
`title` varchar(255) NOT NULL default '',
`filename` varchar(255) NOT NULL default '',
`content` text NOT NULL default '',
`status` smallint(6) NOT NULL default '0',
`created_time` datetime NULL,
`update_time` datetime NULL,
PRIMARY KEY (`web_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$installer->endSetup();

34. 后台模块开发(1)相关推荐

  1. ThinkPHP 3.2.3 简单后台模块开发(一)常用配置

    一.项目分组 下载解压 ThinkPHP 3.2.3,在默认的应用 Application(./Application) 中,包含一个默认的模块 Home(./Application/Home). 需 ...

  2. 【Linux后台开发系列】Nginx源码从模块开发开始,不再对nginx源码陌生丨源码分析

    Nginx源码从模块开发开始,不再对nginx源码发怵,值得学习,认真听完. 1.  nginx的conf配置,cmd解析 2.  nginx模块的八股文 3.  nginx开发的细枝末节 [Linu ...

  3. discuz 后台页面开发

    后台页面开发 创建项目 在 ./source/admincp/menu/ 目录下创建 menu_mynav.php 文件 在"管理中心-全局"中加一个项目,需要在 menu_myn ...

  4. 这可能是东半球最保姆级的后台服务器开发学习路线

    作者 | 编程指北 来源 | 编程指北(id :cs_dev) 前言 这一篇的主题是「Linux C/C++ 服务器/后台开发学习路线」. 这样的文章相信大家都见得不少了,写之前也非常忐忑,能不能和其 ...

  5. Nginx 模块开发

    Nginx 模块概述 Nginx 模块有三种角色: 处理请求并产生输出的 Handler 模块: 处理由 Handler 产生的输出的 Filter(滤波器)模块: 当出现多个后台服务器时,Load- ...

  6. Android开发之ApiCloud模块开发的注意事项

    经过本人多次模块制作打包上传基本总结模块开发的以下坑: 一.模块开发SDK最小版本必须为9,不然就算你SDK模块开发完毕正常运行你在后台云编译也无法通过会报错,提示 minSdkVersion9小于你 ...

  7. 第11步 git推送失败 用户模块开发

    别忘了git push **************************************************************************************** ...

  8. php magento 开发,magento 2模块开发实例helloworld模块 hello world 程序 c语言hello world代码 c语言hello worl...

    data-id="1190000005008433" data-license="cc"> 1.在app/etc/config.php中添加自定义的模块( ...

  9. idea如何做到多模块开发项目

    首先,推荐两个不错的后台系统模板,非常的不错,力荐. 1.码云地址:BootDo后台管理系统 2.码云地址:若依后台管理系统 因为之前一直在用BootDo后台管理系统模板,一直是在一个项目中开发.后来 ...

  10. Xposed模块开发指南

    1.Xposed框架是什么? Xposed框架是一款开源框架,其功能是可以在不修改APK的情况下影响程序运行(修改系统)的框架服务,基于它可以制作出许多功能强大的模块,且在功能不冲突的情况下同时运行. ...

最新文章

  1. 手机APP功能测试经验分享2016.06.06
  2. java的CyclicBarrier使用
  3. 历代CPU最全明细参数表
  4. LeetCode 643. Maximum Average Subarray I
  5. PAT乙级(1004 成绩排名)
  6. Eclipse用法和技巧十八:减少不必要的输入
  7. [deviceone开发]-土地销售App开源
  8. 微信Windows版如何从旧电脑迁移聊天记录到新电脑
  9. 房产中介管理系统网站完整源码
  10. Photoshop中曲线调整如何恢复
  11. 真无线蓝牙耳机哪个音质最好?2021入门级蓝牙耳机排行榜!
  12. 官方rom提取原签名工具_官方和第三方ROM的提取与分解
  13. nodejs生成uid
  14. 人的一生需要经历很多的磨难和痛苦
  15. SQL REGEXP_SUBSTR的用法
  16. 【Shecan Notes】从二叉树出发浅谈风险中性定价
  17. eChart 中 柱状图、地图、AntDesign 的 滚动条表格、highChart 的 (venn) 韦恩图
  18. P8311 [COCI2021-2022#4] Autići
  19. 用QT制作图片转换成ICO格式 领卓教育
  20. python输入城市名称_「Python」每日一练:列表创建身份证城市代码

热门文章

  1. 易普优APS 5.0高级计划排程系统助力工业4.0智能工厂建设
  2. 装饰模式 -- 大话设计模式
  3. java用Calendar计算年龄的问题
  4. 45本Hadoop、大数据方向书籍,包邮送到家!
  5. es6(var,let,const,set,map,Array.from())
  6. 兔子问题or斐波那契数列
  7. java-程序流程控制
  8. Eclipse srever起来时,时间超过45s。
  9. 【转】Linux删除文件未释放空间问题处理
  10. 第一百天 how can i 坚持