Problem with routing in different methods

argian
Member | 15
+
0
-

Hi,

I am tring to route my application as described below:

$router[] = $list = new RouteList(‘Front’);

$list[] = new Route(‘museums/<category>/<sortby>/’, ‘Museums:MuseumsByCategory’);
$list[] = new Route(‘museums/’, ‘Museums:default’);
$list[] = new Route(‘<presenter>/[<slug>/][<id>/]’, ‘Homepage:default’);
return $router;

The methods are:

public function renderDefault(): void {..}
and
public function renderMuseumsByCategory(string $category, string $sortby): void {}

The links are created in the latte file as
<a n:href=":Front:Museums: ‘category’, ‘valuation’ ">Category</a></li>

The error is
Invalid link: Passed more parameters than method App\Modules\Front\Presenters\MuseumsPresenter::renderDefault() expects.

Why it calls default instead of MuseumsByCategory?

What I am doing wrong?

Any idea?

Thank you.

Marek Bartoš
Nette Blogger | 1273
+
+2
-

Link generating does not depend on order of routes. If you don't define action, it uses default

<a n:href=":Front:Museums:museumsByCategory 'category', 'valuation' ">

argian
Member | 15
+
0
-

Yes! I forgot to call the method. That's why programming needs two.

Thank you.