Problem with go() in controller

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.

have you tried with another slash?

/m:thank-you/#anchor

yes, does not help. :frowning:

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

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);
    }
  )
));

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

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 :wink:

S.

since you are indirectly using toolkit router… try (:all) instead of (:any). different regex pattern.