I do not know where Yii is looking for my views

Hi folks, new user here.

I understand my views follow the /protected/views/ControllerName/ActionName convention. My TreeController’s actions were resolved without an issue under /protected/views/tree.

In an attempt to mimic the web app generated by yiic, I made a base controller in the /protected/components directory called ArboretumController and started to subclass it instead of CController.

I then got errors telling me Yii could not find TreeController’s views, so I assumed that Yii started to look under a views subdirectory in /protected/components. However, duping the views did not help. These are the paths I’ve tried to put my views in:


/protected/views/tree

/protected/views/arboretum/tree

/protected/components/views/tree

/protected/components/views/arboretum/tree

I have also tried overriding CController::getViewPath(), which did not help.

I can solve this problem myself if I knew how to dump the variables Yii is using before the error is encountered.

Where is Yii looking for my views? I have checked the docs and forums, but the information I found has not helped me solve my problem.


<?php


    class ArboretumController extends CController {

        

        // anon sessions ok    

        protected $session;

        

        public function __construct() {

            $this->session = new CHttpSession;

            $this->session->open();

        }    

    }




<?php


class TreeController extends ArboretumController

{

        public function __construct()

        {

            parent::__construct();

        }

    

	public function actionIndex($page = 'index')

	{        

        /*

        To avoid a fat controller with one action set for each

        possible page of a session-based stateful form,

        we select the form view based on a seperate GET argument

        outside of the route.

        */

        

            $this->beginContent();

        

            $this->beginWidget('PagedFormWidget', array(

                'session' => $this->session

            ));


            $this->renderPartial($page);    

            $this->endWidget();

            $this->endContent();

	}

}



Hi and welcome to the Yii forum.

It’s not “ActionName” but “ViewName”… i.e. the view name you put as the first argument when calling render/renderpartial. - http://www.yiiframework.com/doc/guide/1.1/en/basics.view

Hi there,

It looks like your problem stems from overriding the __construct() method without calling the parent in ArboretumController.php

Calling parent::__construct() with the proper arguments for CController.php’s implementation should fix your issue.




<?php


    class ArboretumController extends CController {


        // anon sessions ok

        protected $session;

        public function __construct($id,$module=null) {

            $this->session = new CHttpSession;

            $this->session->open();

            parent::__construct($id, $module);

        }

    }



That seemed to solve my problem. Thank you very much for the prompt, friendly and helpful responses!