8.4.1 passing value to view() via URL works in Dashboard single page but not in block

Permalink
I pass a value from view to controller's view via the URL in a Dashboard single page.

Dashboard single page view:
<li><a href="<?php echo \URL::to('/dashboard/cars/', $category->getCategoryID()); ?>"><?php echo $category->getCategory(); ?></a></li>

Dashboard single page controller:
public function view($categoryID = null)
    {
        $cars = new CarList();
        $cars->setCategoryID($categoryID);
        $cars->setItemsPerPage(10);
        $paginator = $cars->getPagination();
        $pagination = $paginator->renderDefaultView();
        $this->set('cars', $paginator->getCurrentPageResults());
        $this->set('pagination', $pagination);
        $this->set('paginator', $paginator);

My block controller view() is the same as the Dashboard single page controller view(). And my block's view.php:
<li><a href="<?php echo \URL::to('/cars/', $category->getCategoryID()); ?>"><?php echo $category->getCategory(); ?></a></li>

where the /cars page has a block of cars list and links to car categories (same as the topic list). So when you click on the category it should go to the selected car category page view, i.e. /cars/1 should show only those cars with category ID = 1.

The code works perfectly in the Dashboard but not in the block. When it goes to /cars/1, it says Page Not Found. If I explicitly set the category ID in the controller '$cars->setCategoryID(1);' - this works!

What's wrong in the block?

Thank you.

linuxoid
 
linuxoid replied on at Permalink Reply
linuxoid
Ok, I got it!

I changed the block's view categories URLs:
<li><a href="<?php echo \URL::to('/cars/categories/', $category->getCategoryID()); ?>"><?php echo $category->getCategory(); ?></a></li>

and added an action function to the controller:
public function action_categories($categoryID = null)
    {
        $this->view($categoryID);
    }


FYI:https://documentation.concrete5.org/developers/working-with-blocks/c...