# |
Feb 17th 2020, 22:33 |
k4t |
ok |
# |
Feb 17th 2020, 22:31 |
ndm |
Hence I rest my case :) Fix that, and then go from there and fix the additional problems. |
# |
Feb 17th 2020, 22:30 |
ndm |
@k4t When your custom route is asked to do the matching, the first connected route will fail, as it doesn't match the `action`, but since you do not account for that case, and append `/` to whatever `parent::match()` returns, the matching will always be "successful" for the outside world, as the method will always return a string (`false . '/'` equals `/`). |
# |
Feb 17th 2020, 22:26 |
challgren |
Im just throwing ideas out at this time |
# |
Feb 17th 2020, 22:26 |
challgren |
Kind of how the pages example is https://github.com/cakephp/app/blob/master/config/routes.php#L70 |
# |
Feb 17th 2020, 22:26 |
challgren |
What about replacing the slug with *? |
# |
Feb 17th 2020, 22:25 |
ndm |
The route catching basically everything would be a perfect explanation for the behavior that you described |
# |
Feb 17th 2020, 22:25 |
ndm |
I'd say you probably have _additional_ problems, not that the route isn't responsible for the initial problem |
# |
Feb 17th 2020, 22:25 |
k4t |
well it will work, but to build correct parameters I will have to add a bit more logic to the code and I wanted to avoid that |
# |
Feb 17th 2020, 22:23 |
k4t |
I think that soething is wrong when request contain passed parameters (in my example this is slug) |
# |
Feb 17th 2020, 22:23 |
challgren |
Ok since you used a _name what about using that in the link? |
# |
Feb 17th 2020, 22:22 |
k4t |
but generally u r right, I should add logic for "false" |
# |
Feb 17th 2020, 22:21 |
k4t |
url is still generated wrong |
# |
Feb 17th 2020, 22:21 |
k4t |
and I think this is not the problem here, as when I remove my custom Route class from routes |
# |
Feb 17th 2020, 22:21 |
k4t |
with one exception - it will add '/' at the end |
# |
Feb 17th 2020, 22:21 |
k4t |
my route should do exactly what CakePhP DashedRoute is doing |
# |
Feb 17th 2020, 22:18 |
ndm |
@k4t You do not account for non-matching URLs, `parent::match()` can return `false` |
# |
Feb 17th 2020, 22:17 |
k4t |
looks like I have to build urls manually ;/ |
# |
Feb 17th 2020, 22:16 |
ndm |
Well, I don't know what to say about that, I'd have to dig up the discussion in Github. Looking at how `Router::parseRequest()` and `Router::reverseToArray()` return the query arguments in `?`, I'm not sure if I should trust the docs. |
# |
Feb 17th 2020, 22:11 |
challgren |
@ndm “Router will also convert any unknown parameters in a routing array to querystring parameters. The ? is offered for backwards compatibility with older versions of CakePHP.” |
# |
Feb 17th 2020, 22:10 |
k4t |
oO |
# |
Feb 17th 2020, 22:10 |
k4t |
when I remove customer route class and I am on page "/meine-ausgaben/abcd" then HTMLHelper will give me "/my-editions/view?t=test" |
# |
Feb 17th 2020, 22:05 |
k4t |
here u can see how routes r defined |
# |
Feb 17th 2020, 22:05 |
k4t |
https://gist.github.com/K4T/b8f34b86138d2149e25329e6427b93eb |
# |
Feb 17th 2020, 22:03 |
challgren |
Like @ndm said it might be your route connection |
# |
Feb 17th 2020, 22:03 |
k4t |
that is what I wanted to ommit |
# |
Feb 17th 2020, 22:02 |
challgren |
You might need to specify your action then |
# |
Feb 17th 2020, 22:02 |
k4t |
@challgren both gave the same results |
# |
Feb 17th 2020, 22:01 |
challgren |
4.x docs have `echo $this->Html->link(‘View image’, [ ‘controller’ => ‘Images’, ‘action’ => ‘view’, 1, ‘?’ => [‘height’ => 400, ‘width’ => 500] ]);` |
# |
Feb 17th 2020, 22:01 |
ndm |
I'm not really sure, I just vaguely remember the back and forth about |
# |
Feb 17th 2020, 22:00 |
challgren |
Ohh it might be |
# |
Feb 17th 2020, 22:00 |
ndm |
I thought that was deprecated that in favor of explicitly using `?`? |
# |
Feb 17th 2020, 21:57 |
challgren |
@k4t it should be <?= $this->Html->link(‘E-Paper’, [‘t’ => ‘test’]); ?> |
# |
Feb 17th 2020, 21:56 |
ndm |
What's the connected route for that? |
# |
Feb 17th 2020, 21:55 |
k4t |
:S |
# |
Feb 17th 2020, 21:55 |
k4t |
it is a bit funny thing because when I am on "/meine-ausgaben" it will generate "/meine-ausgaben?t=test" but when I am on: "/meine-ausgaben/abc" it will generate "/" |
# |
Feb 17th 2020, 21:54 |
ndm |
Generally that should work I think. |
# |
Feb 17th 2020, 21:52 |
k4t |
<?= $this->Html->link('E-Paper', ['?' => ['t' => 'test']]); ?> this gives me "/" even if I am not on the "/" page |
# |
Feb 17th 2020, 21:51 |
k4t |
@ndm do you have idea how I can append query string to current url in the view with HTML helper? |
# |
Feb 17th 2020, 21:45 |
ndm |
you're welcome |
# |
Feb 17th 2020, 21:44 |
k4t |
thats true |