N
N
Nikolai Gromov2017-06-02 06:02:09
Zend Framework
Nikolai Gromov, 2017-06-02 06:02:09

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'=>???]]); ?>

Tell me how to get the id out of it correctly?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
novrm, 2017-06-10
@T_verdisla_V

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.                                   |
 '---------------------------------------------------------------------------------------'

4
4iloveg, 2017-06-02
@4iloveg

Set up xdebug and see what is in the desired variable

N
Nikolai Gromov, 2017-06-05
@T_verdisla_V

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
        ]);

and substitute it in the display of the paginator widget
<?php 
    $this->paginationControl($products, 
            'Sliding',
            'application/partial/paginator', 
            ['route' => 'shop/category', 'params'=>['id'=>$categoryId]]); 
?>

Widget not showing!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question