How to define location of views for the Yiic generated GRUDs

Hey, I just fired up a new project, and made Yiic generate me models and gruds for 4 tables i had.

All worked fine, and, i have 4 controlelrs (one each table) and also 4 diferent directories for the views regarding those controllers. (all normal here, fully automated by Yiic)

Now my problem, in the Views directory, each of the tables views (for crud) are in their "private" directory, each containing several PHP files for the several actions we might need (create.php, list.php, etc), but, i want to keep them inside another directory called "crud" so it would be :

webApp/protected/views/crud/"tablename" ("tablename" beeing the name for the directory with all crud php files in it)

Instead of :


Why? To keep things organised… say i had 50 tables instead of just 4.

If it would be possible for the Controllers too would be awsome, but, for now I just want to know how i can circumvent the "convention over configuration" for this specific case.

PS: From the example, the "site" controller can have their views inside a "site" directory because it uses them for actions, right? (cant seem to find a configuration for that), but i want to keep the code structure of each tables crud beeing in their own Controller instead of polutting it with more actions.

PS2: remember, i didnt change anything from the default output Yiic gives except for DB configuration to generate the crud and models for the 4 tables. And the "crud" folder, to keep things organized.



Ah! The power of conventions over configurations, I just put all my controllers (for each of the tables) inside a folder called crud, and updated the links and it all started working again. Love it =)

For future reference, heres how i solved it.

Links updated to ("comentarios" is one of the table names):

array(‘label’=>‘Comentarios’, ‘url’=>array(’/crud/comentarios’)



Views :

webApp/protected/views/crud/comentarios/ (then the rest of view files here)

I think you have to extend crud command. Please refer this cookbook: How to extend yiic shell commands for more detail. I think if you will create your own command with another path. I think you have to overwrite method generateView of CrudCommand.php and also

    public function generateView($source,$modelClass)






        if(!is_file($source))  // fall back to default ones


        return $this->renderFile($source,array(





and additionally in you "base controller" for all controllers you are using for "cruds", ypu have to modify methods:

getViewFile() and getViewPath().