Render Failing Due To View Being Not Found?

So, I have a project with multiple controllers and all has been good but I’ve run into a situation where in my UserController it’s unable to find the ‘index’ view… it’s in protected/user/view/index.php

I tried setting render(’//user/index’) and that caused $this->getViewFile($view) in the framework\web\CController.php to report ‘UserController cannot find the requested view “_view”.’

When I substitute in render(’//site/index’), it loads the site index.php view properly

  echo "UserController::Index() -> <pre>";


  print_r($this->getViewFile('index'));


  exit;;

shows the output

UserController::Index() ->

Can anyone tell me why they think getViewFile() might return null for this?

I looked for a setViewFile(), but don’t see it. I’ve run into the problem before that suddenly I have to add //site/viewname to my render() calls before vs just viewname, and I don’t know why

Anyone run into this before and can make sense of the what I’ve relayed so far?

thanks

Yii looks for view files to render in protected/views/controllerName/viewName.

So, you need to put the index view file for your user controller in the protected/views/user directory. :)

Yea, sorry, I miscommunicated that. The index.php in the correct location. When I swapped out user and site, the userController loads/renders the “/site/index”… I’ve created literally hundreds of views and controllers, just sometimes, with some of my yii apps, this scenario happens, and I haven’t been able to figure out why yet. Hopefully I’ll figure it out and I’ll update this post when I do if no one has a clue here.

thanks for trying

If you put this in the index action of your User controller, it won’t use the index view of the site controller:





		$this->render('index');



If it does, something is really funky.

if I put that into the UserController, it’s going to load the view\user\index.php

What I was saying is that if I fully qualify the render("\views\$controller_name\$view_name") using the $controller_name=‘site’, that it works as expected and loads the site’s index.php

Again, I appreciate you trying, but it’s obvious that this problem is mine to solve. I’m juggling multiple projects, so when I get back to this one and solve it, I’ll explain what the remedy was if I discover it.

Thanks again for trying

$this->render(‘index’)

works for me…