Svnt
1
hello,
i’ implementing a comment system… works well but the return does not work as expected:
The “go()” should set a parameter “m” and the page should jump down to an anchor.
go('/m:thank-you#anchor');
brings me to the homepage with parameter and anchor jump, nice!
BUT:
go($page->url().'/m:thank-you#anchor');
brings me to the actual blog post but the “m” and “anchor” part is missing from the URL.
What i’m doing wrong?
bestRegards,
Sven
PS:
header::redirect($page->url().'/m:thank-you#anchor');
also does not work. #anchor is there /m: not.
bnomei
2
have you tried with another slash?
/m:thank-you/#anchor
bnomei
4
url-helper for root seems to work. so try page uri instead of url?
go($page->uri().'/m:thank-you#anchor');
https://getkirby.com/docs/cheatsheet/page/uri
Svnt
5
The problem is my router. It removes the “/blog/” subfolder from the URL… and the parameter too… but why?
(the code is from https://getkirby.com/docs/developer-guide/advanced/routing …at the bottom)
/*-------------------------------------
Setup Kirby Routes
-------------------------------------*/
c::set('routes', array(
array(
'pattern' => '(:any)',
'action' => function($uid) {
$page = page($uid);
if(!$page) $page = page('blog/' . $uid);
if(!$page) $page = site()->errorPage();
return site()->visit($page);
}
),
array(
'pattern' => 'blog/(:any)',
'action' => function($uid) {
go($uid);
}
)
));
bnomei
6
using php header redirect and anchor is not well supported. you might have to use a proper url param and query that with js.
go($page->url().'/m:thank-you?goto=anchor');
http://stackoverflow.com/a/30754564
Svnt
7
Hm, ok. But as i told: without the router it works fine.
I’ll “fix” it with a special “thank you”-page for now.
Thanks for your help… and if anybody have a idea how to fix this router problem… pls tell me 
S.
bnomei
8
since you are indirectly using toolkit router… try (:all)
instead of (:any)
. different regex pattern.