作者在 2008-04-20 10:46:46 发布以下内容
原文出处:http://forum.kohanaphp.com/comments.php?DiscussionID=121&page=1#Item_0
以下是本人根据原文意思对使用方法进行中文化整理的结果,还没具体实践过:
原文件下载地址: 点击这里
解压缩后放到Kohada->application->modules目录里, 然后在config.php的适当位置添加如下字段:
$config['modules'] = array
(
'modules/auth', // Authentication
'modules/forge', // Form generation
'modules/grige', // Grid generation
// 'modules/kodoc', // Self-generating documentation
// 'modules/media', // Media caching and compression
)
看这些源代码,它真的很简单。
简短样例:
$grid->add_new_button('new', 'add new album'); //Adds the "create new" button to the grid
$grid->field('artist')->label('Artist'); // set the label for artist field. The label will be shown as a column heading
$grid->field('title')->label('Album');
$grid->field('year')->label('Year');
$grid->action_field('id') //the field, that will be passed to the link as a parameter
->label('Edit') //Column label
->url('admin/album/'.'edit') //the uri for building the link
->action('Edit'); // the row text
//the URL will look like that: http://localhost/kohanasvn/admin/album/edit/1
$grid->action_field('id') //See above
->label('Видалити')
->url($this->base_uri.'delete')
->action('Видалити');
$album = new Album_Model; //Getting albums
$album->orderby('title', 'asc')->where('published', 1);
$grid->datasource(
$album->find_all()
);
$this->template->content = $grid; //Adding the grid to the page
该样例不包含分页功能,建议你在实际应用中应用Pagination类库加以扩展。