Hello Phalcon community,
I have problem with routing and generating URLs who have more than one value separated by colon. I found one discusion here about that (https://forum.phalcon.io/discussion/2746/use-colon-as-seperator-in-url) but that was about one value separated by colon.
I'm trying to reach something like this:
- https://example.org/movies - Page for all movies
- htp://example.org/movies/page:10 - Page no. 10 for all movies
- https://example.org/movies/page:12/sort:created - Page no. 12 for all movies sorted by created field
So I created model, views and controller for that, and in routes.php I added something like this:
...
$router->add('/movies', "Movies::allMovies")->setName('movies-index');
$router->add('/movies/page:([0-9]+)', array(
'controller' => 'movies',
'action' => 'allMovies',
'page' => 1
))->setName('movies-index-page');
$router->add('/movies/page:([0-9]+)/sort:([a-z]+)', array(
'controller' => 'movies',
'action' => 'allMovies',
'page' => 1,
'sort' => 2
))->setName('movies-index-page-sort');
...
In controller I'm receiving this data via dispatcher and it works fine. Problem is starting when I'm trying to generate URL via {{ url(["for"]) }}
or {{ link_to(["for"]) }}
.
For router named "movies-index" everything works fine, and url function generates me a proper URL address, same thing happens for movies-index-page ({{ url(["for": "movies-index-page", "page": ":10"]) }}
). I have a problem when I'm trying generate URL with second parameter separated by semicolon. When i write something like this:
{{ url(["for": "movies-index-page-sort", "page": ":12", "sort": ":created"]) }}
URL function generates me something like this:
/movies/page:12:created/sort
I have tried everything. I even tried solving that problem with documentation (https://docs.phalcon.io/en/latest/reference/dispatching.html#preparing-parameters) but without any positive result :(
II'll be grateful for any hint to solve this problem :)
P.S. Sorry for my rusty English. It isn't my native language but I'm trying as best I can :)