I have a URL: /7.0/7.1/7.1.1/7.1.1.4, but trying to access "7.1.1.4" via twig. The
TWIG
{{uri.path}}
Outputs the entire path.
Solved by Claud Rusnac View solution
I have a URL: /7.0/7.1/7.1.1/7.1.1.4, but trying to access "7.1.1.4" via twig. The
{{uri.path}}
Outputs the entire path.
You want to output the page slug: https://learn.getgrav.org/themes/theme-vars#slug
I ended up using:
{{uri.path|split('/')|last|split('-')|first}}
since in needed the actual URI that was passed. I am using this on the error.md page, so I couldn't use the slug because it would always show up as "error"
Log in to reply.
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 5 | 148 | 13 hours ago | ||
| 1 | 192 | 1 week ago | ||
| 1 | 241 | 3 weeks ago | ||
| 4 | 375 | 1 month ago | ||
| 4 | 744 | 3 months ago |