Yii Framework Forum: yii2 render page in smarty(.tpl file) - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

yii2 render page in smarty(.tpl file)

#1 User is offline   Hamed" B 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 26-February 18

Posted 26 February 2018 - 01:57 AM

How to change this code in .tpl files?

1)
$ this-> render ('_form', [
     'model' => $ model,
 ]);


2)
GridView :: widget ([
                                         'dataProvider' => $ dataProvider,
                                         'filterModel' => $ searchModel,
                                         'columns' => [
                                                                ['class' => 'yii \ grid \ SerialColumn'],'id','title',['class' => 'yii \ grid \ actioncolumn'],
                                                          ],
 ]);



i changed number 2 to :
{GridView 'dataProvider'=$dataProvider,'filterModel'=$searchModel,columns=[  
                                                        ['class' => 'yii\grid\SerialColumn'],
                                                        'id',
                                                        'title',
                                                        ['class' => 'yii\grid\ActionColumn'],    ]
 } 


but this error Happened !! => "too many shorthand attributes"
0

#2 User is offline   Hamed" B 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 26-February 18

Posted 27 February 2018 - 03:30 AM

For Gridview

{GridView::widget([
          'dataProvider' => $dataProvider,
          'filterModel' => $searchModel,
          'columns' => [ 
               ['class' => 'yii\grid\SerialColumn'],
               ['attribute' => 'id'],
               ['attribute' => 'title'],
               ['class' => 'yii\grid\ActionColumn']
          ]
])}


And use it in top of the page
{use class="yii\grid\GridView"}



To render a tpl use:
{$this->render('_form.tpl', ['model' => $Model])}

0

#3 User is offline   jim. 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 182
  • Joined: 28-June 12
  • Location:Germany

Posted 27 February 2018 - 04:48 AM

Please wrap your code with

[code] 
[/code]

so it´s better readable.
1

#4 User is offline   Hamed" B 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 26-February 18

Posted 04 March 2018 - 03:12 AM

 jim., on 27 February 2018 - 04:48 AM, said:

Please wrap your code with

 your code 


so it´s better readable.


done! tank you for your comment.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users