案例:导出,下载, 上传等。有一个CsvController类,有一个index.php可以实现csv导出功能。内容如下:
- <?php
- class CsvController extends CController{
- public $defaultAction='index';
- public function actionIndex(){
- // do csv exporting.
- }
- }
upload
- <?php
- class UploadController extends CController
- {
- public function actions()
- {
- return array(
- 'upload' => array('class' => 'application.extensions.KEditor.KEditorUpload'),
- 'manageJson' => array('class' => 'application.extensions.KEditor.KEditorManage'),
- );
- }
- }
1. 把CsvController.php放到protected/extensions/csv目录下。
2. 在protected/config/main.php中设置
- return array(
- 'defaultController' => 'site',
- 'controllerMap'=>array(
- 'csv'=>array(
- //Yii::setPathOfAlias('backend', $backend);通过定义别名可以放在任意位置
- 'class'=>'backend.extensions.csv.CsvController'
- ),
- 'upload'=>array(
- 'class'=>'application.extensions.KEditor.UploadController'
- ),
- )
- )
现在就可以这样调用了
http://localhost/path/to/index.php?r=csv/index
时间: 2024-10-02 06:20:48