I am having a problem where a Gii created model / CRUD is not pointing to the correct links. I created a new model called ‘resources’ that lets admins upload pdf’s to the server for users to download. The problem I am having is that when a view is rendered it is not including /resources/ in front of the view name. This is causing Yii to not be able to find any of the views. I can manually add ‘/resources/’ to all the render calls but this doesn’t seem like the best method.
So my question is, where does Yii set the base path for a controller to call its’ views and does anyone know how this could have been garbled for just this one model?
OK so I figured out why it was happening… I had created a ResourcesController function in the ResourcesController class in order to set the layout file based on whether or not a user was logged in and if I comment it out, the links work again.
The code looks like this:
public function __construct() {
if (Yii::app()->user->hasRole(array('ResourceManager','admin')))
$this->layout='column2';
else
$this->layout='column1';
}
Obviously I am missing something in here but I am sure there is an event driven function that I can use instead of __construct to set the layout. Time to dig deeper.