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.
Community guidelines
Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.
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 |
|---|---|---|---|---|
| 4 | 193 | 2 months ago | ||
| 3 | 90 | 2 months ago | ||
| 11 | 449 | 3 months ago | ||
| 0 | 43 | 3 months ago | ||
| 5 | 123 | 3 months ago |