Rendering Pagination In Listview




$widget = \yii\widgets\ListView::begin([

        'dataProvider' => $provider,

        'itemView' => 'parts/_company',

        'emptyText' => 'No results.',

        'summary' => '',

        'itemOptions' => [

            'tag' => 'article',

            'class' => 'company-module clr',

        ],

        'options' => [

            'class' => 'list clr'

        ],

    ]);



I have a widget that uses data provider and i have rendering in another part of file.




   <?php $widget->renderItems();  ?>

   <?php $widget->renderPager(); ?>

   <?php $widget->end(); ?>



And i cant get pagination to load outside items container (list clr). Is it possible to separate it in html?




$widget = \yii\widgets\ListView::begin([

    'dataProvider' => $provider,

    'itemView' => 'parts/_company',

    'emptyText' => 'Nema rezultata za traženu pretragu.',

    'summary' => '',

    'itemOptions' => [

        'tag' => 'article',

        'class' => 'profile-module clr',

    ],

    'layout' => '{items}'


]);


?>






        <div id="content">

            <div class="list clr">

                <?php echo $widget->renderItems(); ?>

            </div>

            <?php echo $widget->renderPager(); ?>

        </div>



I had to remove $widget END call to make it work.

You may try editing your layout template to make this more simple:




$template = <<< EOL

<div id="content">

    <div class="list clr">

       {items}

    </div>

    {pager}

</div>

EOL;

echo ListView::widget([

    'dataProvider' => $provider,

    'itemView' => 'parts/_company',

    'layout' => $template

]);