404 Error

I’m not sure how to identify the issue I’m having, so please forgive the generic topic title. (newbie)

I have a class for location and a class for invoice, I’m displaying all the invoices for a specific location on a location view. When I click on the link for the invoice I get an Error 404 The requested page does not exist. The problem is the the routing in the browser shows: //localhost/weaccount/index.php?r=location/view&id=4 it should show: //localhost/weaccount/index.php?r=invheader/view&id=4. Since I’m not sure how to lable this issue I can’t search and find others who have had the problem to figure out the fix. The initial page shows the location and then a listview from invheader, its when I click on one of the items int he listview from invheader that I get the 404 error.

See attached screen shot.

The code in LocationController.php:

public function actionView($id)


	$invheaderDataProvider=new CActiveDataProvider('Invheader', 









	$this->render('view', array(





The code is /location/view.php

<h1>View Location #<?php echo $model->locationId; ?></h1>

<?php $this->widget(‘zii.widgets.CDetailView’, array(








)); ?>

<br />


<?php $this->widget(‘zii.widgets.CListView’, array(



	)); ?&gt;

How is the invoice link generated in /invheader/_view ?

Seems that you have to use Yii::app()->createUrl(…) instead of $this->createUrl(‘invheader’,…) to create the url to the InvoiceController, because the current controller is the locationController.

The reason you are getting r=location/view&id=4 is probably the way that CListview generates the ‘view’ link. I believe it uses $this-> which is the current controller. You can do one of two things:

  1. extend CListview to add a variable for the controller you want and over write the code that generates the link.

  2. modify actionView in the LocationController to generate the view from what ever view directory you want. ie:

public function actionView($id) {


    if (isset($id)) {

        $this->render('/invheader/view', array('id'=$id));

    } else {



Thanks for your replies.