Wednesday, November 9, 2011

How to renderPartial a file in another controller’s view folder for Yii

We can use renderPartial to access a partial file that is stored in a different controller’s view folder.

In Yii 1.1.3, we use the double slash “//” to locate the partial file starting from the views folder. The example below locates a partial stored in
protected/views/library/_book.php
 $this->renderPartial('//library/_book', array('books'=>$books))?>
Using single slash “/” will start the searched from the current active module’s view path instead, and falls back the search in the application’s view path.

2 comments: