(:any) Route Placeholder Not Working? |
Documentation states that the (:any) placeholder should return the remainder of the URI string, but in my implementation, I only ever get the next segment. Everything after the proceeding / is truncated. Am I doing something wrong?
Routes.php -Route Definitions Code: $routes->get('auth/', 'Auth::index',['namespace' => 'IonAuth\Controllers']); Pages->View() Code: public function view($slug = null) If I enter a url like http://www.example.com/docs/tutorial I would expect $slug to be "docs/tutorial" Instead all I get is "docs"; Am I setting something up incorrectly? Thanks!
Can you link that part of the documentation, so it can be corrected.
That's for catching any character in the first /segment/. You can however get them with: https://codeigniter4.github.io/userguide...i-segments Nevermind... (: segment) are one segment. Will take a closer look at this.
You need to catch it as an array. So it's working. :-)
PHP Code: public function view(...$segments)
Thanks so much. I appreciate the assistance.
For anyone else hoping to pull it down as a full string, the view function needs to be as follows: PHP Code: public function view(...$slug)
There are a function for that, if you just wanted it as a string.
https://codeigniter4.github.io/userguide....html#path
Doesn't work on me. It always return "Can't find a route for". I still can't figure it out.
Put a / slash in front of it /(:any)
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |