Error 404

Error 404

The system is unable to find the requested action "department".

I am a ‘Raw Newbie’ trying to expand upon Larry Ullman’s introductory tutorial on Yii where you create an employee MVC and department MVC. I want to add an item to the skeleton webapp menu bar created by yiic, which I have successfully done by adding the following line:

array(‘label’=>‘Department’, ‘url’=>array(’/site/department’)),

To the Cmenu widgit in the /protected/views/layouts/main.php file,

The site displays my item with its label "Department" upon loading.

When I try and click on "Department" I get:

[b]Error 404

The system is unable to find the requested action "department".[/b]

When I look in : /protected/views/site : there is no entry for department.php. Do I need to create the department.php or can it be found in another location and moved to the ‘site’ location?

                	Thanks for your patience and understanding,





                                                  	Steve

You can reach me at slk00@comcast.net

yes you need to create department.php and department action in site controller to render this view

You need to create a department action in your site controller.

In protected/controllers/SiteController.php,




<?php


class SiteController extends Controller

{

    ...

    

    public function actionDepartment()

    {

        $this->renderText('Hello');

    }

}



You’ll obviously want to render a view instead of text.

So you have already created Employee CRUD and Department CRUD with Gii? No need to modify SiteController or anything in views/site then. Just use the appropriate controller id/action id routes in CMenu:




array('label'=>'Department', 'url'=>array('/department/index')),

array('label'=>'Employee', 'url'=>array('/employee/index')),  



Thank you so much for your help…those two pieces of code worked like a charm and both screens were rendered in my app…Thanks Again