Adding new action

Dear All,

I am new to Yii so kindly bear with me :)

I am working on a small script where there are following things

products

categories

Iteams

now when I have created CRUD for products and categories properly and they are showing results as well.

I have used 2 column layout where on the right panel I am showing all the categories and the items in that and in the left section (content section) I am showing all the products respectively.

so when I go to index.php?r=products I got all the products and category on left side.

Now what I want is when I click on category then the control should go to the page where I can display the products within that category.

Url is like index.php?r=products/show&id=3 where 3 is the category id.

But when I add this action called show in my ProduCtscontroller.php and try to access this url, I am getting an 404 error. It means the system is not reading my new action which I defined in controller.

I did this

public funciton show(){

echo "hi";

}

Question: is there any particular way for adding an action / view to the site ?

Please let me know if you need any more info from my side.

Noddy

Try




public function actionShow(){ // not funciton

 echo "hi";

 }

 



to see it

But don’t forget to allow allowed users to perform ‘show’ actions by adding the action in accessRules() function




	public function accessRules()

	{

		return array(

			array('allow',  // allow all users to perform 'index', 'view' and 'show' actions

				'actions'=>array('index','view','show'),

				'users'=>array('*'),

			),

					);

	}



thanks it’s very helpful and useful