Yii - how to retrieve model data into a layout page?
问题 I wish to list some Categories name on my layout main.php page. Since the layout doesn't have any associated controller or model, I wish to create a static method like this on Category model: public static function getHeaderModels() { // get all models here return $models; } and then in the main layout <?php $models = Category::getHeaderModels(); foreach($models as $model) { // .... } ?> My question is a very basic one: How can I retrieve those category names from the model ? Here is the full