menxaca
(Menxaca)
April 8, 2013, 7:53pm
1
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:
/modules
/modules/causes
/modules/causes/views/cause/view.php
/modules/causes/controllers/CauseController.php
/modules/causes/models/Cause.php
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:
/protected
/protected/controllers/CauseController.php
/protected/models/Cause.php
/protected/views/cause/view.php
and calling like this:
<h5><?php echo CHtml::link(CHtml::encode($data->title), array('/cause/view', 'id'=>$data->id)); ?></h5>
Same error
Thanks
haymps
(Peter Hayman)
April 8, 2013, 8:59pm
2
just a quick guess, but you might remove the leading /. Like this: array(‘cause/view’, ‘id’=>$data->id)
menxaca
(Menxaca)
April 8, 2013, 9:03pm
3
I also tried that, not working
yiqing95
(Yiqing 95)
April 9, 2013, 12:59am
4
did you create the actionView function in your CauseController class .Are the controller and the views generated by gii/giix ?
lalzada
(Lalzadamohmand)
April 9, 2013, 4:54am
5
Hello !!!
paste the below code in ur protected/config/main.php
'import'=>array(
'application.modules.moduleName.models.*',
'application.modules.moduleName.moduleNameModule',
),
'modules'=>array(
'moduleName',
),
and then try this
<?php echo CHtml::link(CHtml::encode($data->title), Yii::app()->createUrl('/moduleName/controller/action', array('id'=>$data->id))); ?>
menxaca
(Menxaca)
April 9, 2013, 5:29pm
6
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!