Skip to content
Grav 2.0 is officially stable. Read the announcement →
Themes & Styling

Slash in url parameter

Solved by Ron Wardenier View solution

Started by T. 6 years ago · 8 replies · 1507 views
6 years ago

In my custom theme, I want to pass a parameter value containing a "Slash"

The parameter value is: Lab/abc and the route is "http:/mysite.com/tags/tag:Lab/abc".

  • The trouble is that the "/" between "Lab" & "abc" is considered as a new route. So it tries to reach a non existing route.

So I've tried to escape the "\" with the "url_encode" function, and it gives me another adress ""http:/mysite.com/tags/tag:Lab%2Fabc" but I'm still reaching a non existing route.

My question is : Is grav support "/" in parameter value ? or is it an advanced settings in Grav?

Thanks for help or suggestion.

6 years ago

Grav should not parse any URL parameter but it does when using the Grav URL parameter notation “key:value”.

A workaround is to use the standard “key=value”.

6 years ago

Hi bleutzinn,

unfortunatly the workaround does not work. "key=value" parameter format drives me to an unkwnown route, even with a regular parameter (no slash in it). Did I miss something?

6 years ago

@Raph31t , @bleutzinn ,

I don't think the 404 error is a matter of : or = but the preceding ? in front of the query paramers.

The : or = do however influence how the query is interpreted.

When using http://blog-dev/?tag:mush/room a dump of URI will show:

TXT
object: Grav\Common\Uri
url: "http://blog-dev/"
...
*query: "tag:mush/room"
*queries: Array(1)
  tag:mush/room: ""                             <-- note the difference
*params: Array(0)

When using http://blog-dev/?tag=mush/room a dump of URI will show:

YAML
object: Grav\Common\Uri
url: "http://blog-dev/"
...
*query: "tag=mush/room"
*queries: Array(1)
  tag: "mush/room"                               <-- note the difference
*params: Array(0)

Conclusion:

  • = gives the correct query parameters

Note:

  • When prepending the querystring with a ?, the plugin 'taxonomylist` won't work out of the box anymore.
last edited 02/10/21 by pamtbaau
6 years ago

Glad you got it working.

Just for future reference, the docs about the URI object distinguishes between 'URL parameter' and 'URL query'. The first being what I call Grav style key:value' or actually '/key:value and the second the standard way: ?key=value.

6 years ago

I noticed in the doc 2 days ago, and started to use the Grav syle, but because of the "/" trouble, I have switched to the standard way.

So you know why Grav has developped its own way ?

6 years ago

No I do not. It looks cool but I doubt that was the only reason

The problematic behavior you encountered is a bug in my opinion. I suggest you open an issue in the Grav core repository so the developers can fix it.

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by stuart young, 2 weeks ago
3 251 2 weeks ago
Themes & Styling · by Sebadamus, 3 weeks ago
5 317 3 weeks ago
Themes & Styling · by martynfoster735, 4 weeks ago
1 310 4 weeks ago
Themes & Styling · by Justin Young, 1 month ago
1 348 1 month ago
Themes & Styling · by Slebeig, 2 months ago
4 474 2 months ago