From Site View Call An Action In A Module

Hi All,

I just don’t know what is happening, I can’t find any error, stupid error for sure. I just want to call an action from a view and I get "Error 404 Unable to resolve the request “causes/cause/view/id/5” all the time.

my module structure is:






The link in index view from siteController:

<h5><?php echo CHtml::link(CHtml::encode($data->title), array('/causes/cause/view', 'id'=>$data->id)); ?></h5>

The action exists in the controller, so I don’t know what happens. Any advise?

Also, I have tried to remove the module and do it without the module as a simple link, no success…

App structure:





and calling like this:

<h5><?php echo CHtml::link(CHtml::encode($data->title), array('/cause/view', 'id'=>$data->id)); ?></h5>

Same error :(


just a quick guess, but you might remove the leading /. Like this: array(‘cause/view’, ‘id’=>$data->id)

I also tried that, not working :(

did you create the actionView function in your CauseController class .Are the controller and the views generated by gii/giix ?

Hello !!!

paste the below code in ur protected/config/main.php








and then try this

<?php echo CHtml::link(CHtml::encode($data->title), Yii::app()->createUrl('/moduleName/controller/action', array('id'=>$data->id))); ?>

Thanks to all for your replies! it was a copy/paste error, I copied the controller from another existing controller, I changed everything, but… I forgot to change the class name! so It had a wrong name a therefore Yii couldn’t find the controller.

Thanks to all again!