This example is to pagination the product list
1. actionlist in Controller
Reference paging class
In actionlist:
$ Goods_info = goods: Find ()-> joinwith ('brand', 'category ')-> orderby ('goods. goods_id DESC ');
$ Brand_model = new brand ();
$ Brand_info = $ brand_model: Find ()-> All ();
$ Pages = new pagination (['totalcount' => $ goods_info-> count (), 'pagesize' => 5]);
$ Goods_info1 = $ goods_info-> offset ($ pages-> offset)-> limit ($ pages-> limit)-> All ();
Return $ this-> render ('LIST', ['goods _ info' => $ goods_info1, 'brand _ info' => $ brand_info, 'brand _ model' => $ brand_model, 'pages' => $ pages]);
2. view page list. php
Use yii \ widgets \ linkpager;
<Div class = "text-Right">
<? = Linkpager: widget (['pagination' => $ pages])?>
</Div>
So far, the default page of yii2 has been completed, and the display effect is
Yii2.0 Paging