Answer the question
In order to leave comments, you need to log in
How to get id in phtml?
Hello! I have a paginator object $products passed to my phtml file.
<?= $this->paginationControl($products,
'Sliding',
'application/partial/paginator',
['route' => 'shop/category', 'params'=>['id'=>???]]); ?>
Answer the question
In order to leave comments, you need to log in
I didn't understand the humor. Just pass the id variable to the view.
No need to shove it into the paginator and try to get the missing from there.
The paginator gives only the following variables to the view, and no more.
.---------------------------------------------------------------------------------------.
| Property | Type | Description |
|---------------------------------------------------------------------------------------|
| first | integer | First page number (typically 1). |
| firstItemNumber | integer | Absolute number of the first item on this page. |
| firstPageInRange | integer | First page in the range returned by the scrolling style. |
| current | integer | Current page number. |
| currentItemCount | integer | Number of items on this page. |
| itemCountPerPage | integer | Maximum number of items available to each page. |
| last | integer | Last page number. |
| lastItemNumber | integer | Absolute number of the last item on this page. |
| lastPageInRange | integer | Last page in the range returned by the scrolling style. |
| next | integer | Next page number. |
| pageCount | integer | Number of pages. |
| pagesInRange | array | Array of pages returned by the scrolling style. |
| previous | integer | Previous page number. |
| totalItemCount | integer | Total number of items. |
'---------------------------------------------------------------------------------------'
I look through var_damp. I tried to pass the id taken from the route into the view
$categoryId = $this->params()->fromRoute('id', -1);
return new ViewModel([
'categoryId' => $categoryId
]);
<?php
$this->paginationControl($products,
'Sliding',
'application/partial/paginator',
['route' => 'shop/category', 'params'=>['id'=>$categoryId]]);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question