diff --git a/themes/berkarar/pages/category.htm b/themes/berkarar/pages/category.htm index 053f2df..dcb9656 100644 --- a/themes/berkarar/pages/category.htm +++ b/themes/berkarar/pages/category.htm @@ -7,6 +7,7 @@ is_hidden = 0 function onStart(){ $id = $this->param('id'); $this['category'] = Tps\Shops\Models\Category::where("id", $id)->get()->first(); + $this['shops'] = Tps\Shops\Models\Shop::where('category_id', $this->param('id'))->paginate(12); } ?> == @@ -44,31 +45,12 @@ function onStart(){
- {% for shop in category.shops%} - {% partial 'home/shop_item' shop=shop %} - {% endfor %} -
-
-
- - -
-
-
-
-
- {% if id != 0%} - {% for category in top_category.categories %} - {% for shop in category.shops%} - {% partial 'home/shop_item' shop=shop %} - {% endfor %} - {% endfor %} - {% else %} - {% for shop in shops%} - {% partial 'home/shop_item' shop=shop %} - {% endfor %} - {% endif %} + {% for shop in shops%} + {% partial 'home/shop_item' shop=shop %} + {% endfor %}
+ + {% partial 'home/pagination' result=shops %}
diff --git a/themes/berkarar/pages/top_category.htm b/themes/berkarar/pages/top_category.htm index 4c0317f..dc64278 100644 --- a/themes/berkarar/pages/top_category.htm +++ b/themes/berkarar/pages/top_category.htm @@ -6,15 +6,18 @@ is_hidden = 0 param('id'); + $this['id'] = $this->param('id'); - if($this['id'] != 0){ - $this['top_category'] = Tps\Shops\Models\TopCategory::where("id", $this['id'])->get()->first(); - }else{ - $this['shops'] = Tps\Shops\Models\Shop::orderBy('created_at')->get(); - } + if($this['id'] != 0){ + $this['top_category'] = Tps\Shops\Models\TopCategory::where("id", $this['id'])->get()->first(); + $categories = $this['top_category']->categories->pluck('id')->toArray(); + $this['shops'] = Tps\Shops\Models\Shop::whereIn('category_id', $categories)->paginate(12); + }else{ + $this['shops'] = Tps\Shops\Models\Shop::orderBy('created_at')->paginate(12); } + +} ?> ==
@@ -51,18 +54,11 @@ function onStart(){
- {% if id != 0%} - {% for category in top_category.categories %} - {% for shop in category.shops%} - {% partial 'home/shop_item' shop=shop %} - {% endfor %} - {% endfor %} - {% else %} - {% for shop in shops%} - {% partial 'home/shop_item' shop=shop %} - {% endfor %} - {% endif %} + {% for shop in shops%} + {% partial 'home/shop_item' shop=shop %} + {% endfor %}
+ {% partial 'home/pagination' result=shops %}
diff --git a/themes/berkarar/partials/home/pagination.htm b/themes/berkarar/partials/home/pagination.htm new file mode 100644 index 0000000..01b6578 --- /dev/null +++ b/themes/berkarar/partials/home/pagination.htm @@ -0,0 +1,93 @@ +{% if result.hasPages %} + +
+
+ {% if result.currentPage > 1 %} + + {% else %} + + {% endif %} + +
+ +
+ + {% if result.hasMorePages %} + + {% else %} + + {% endif %} + +
+ +

+ {{'Всего страниц:'|_}} {{result.lastPage}} +

+
+{% endif %}