Monday, August 15, 2011

Accessing View Files from Anywhere in the Yii Application

By default, view files are accessible using a "double slash" notation, like so:

'//directoryName/fileName'

where 'directoryName' refers to the ID of the view (and, incidentally, its corresponding controller) and 'fileName' is the actual file you wish to use within that directory. For example, if you have a controller called StoreController, it will most likely have a views directory called 'store' in which you might have index.php, update.php or whatever. To include the update.php page from another controller or another view, you can do this:

$this->render('//store/update');

Easy, right?

No comments:

Post a Comment