渲染渲染部分路径主题yii2

时间:2016-09-09 10:42:41

标签: php yii2-advanced-app

我的yii(2)应用程序的结构如下:

   ___Backend
   ___frontend______
  |             |__ controllers
  |             |       |__ SiteController.php
  |             |       |__ ... (other controllers goes here...)
  |             |__ models
  |             |__ views
  |             
  |       
  |       __ 
  |       
  |       :
  |
  |__ themes(my theme)
           |__CompanyProfile
                            |__Index.php
                            |__CSS
                            |__fonts
                            |__...    
  

我使用下面的代码在yii 1中渲染: (yii 1)

public function actionPages($id){
    Yii::app()->theme = 'CompanyProfile';
    $this->renderPartial('CompanyProfile/views/layouts/Index',array(
        'model'=>PrCompany::model()->findByPk($id),
    ));
}`

但是我没有设法在yii2中使用renderPartial。我如何在yii 2中使用renderPartial

1 个答案:

答案 0 :(得分:-1)

public function actionPages($id){
    $this->renderPartial('@frontend/themes/CompanyProfile/views/layouts/Index',array(
        'model'=>PrCompany::model()->findByPk($id),
    ));
}`