N
N
Nikolai Gromov2017-05-01 07:13:47
Zend Framework
Nikolai Gromov, 2017-05-01 07:13:47

What about routes?

Hello! In the main page view file, I have a menu with this code:

<ul id="nav">
                <?php foreach($categories as $category):?>
                    <li>
                        <a href="<?= $this->url('shop/category', ['id' => $category->getId()]);?>"><?php echo $this->escapeHtml($category->getCategory());?></a>
                        <?php if (isset($category->children)):?>
                            <ul>
                                <?php foreach($category->children as $item):?>
                                <li>
                                    <a href="<?= $this->url('shop/category', ['id' => $item->getId()]);?>"><?php echo $this->escapeHtml($item->getCategory());?></a>
                                </li>
                                <?php endforeach;?>
                            </ul>
                        <?php endif;?> 
                    </li>
                <?php endforeach;?>    
            </ul>

the first time I click on a link from the menu, I get this address
zblog.local/shop/category/1

and then the addresses of links from the menu always remain with id=1, tell me what to do? Id must be passed, since the operation of the controller is based on it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question