Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Get url page via twig

Solved by Claud Rusnac View solution

Started by Claud Rusnac 9 years ago · 2 replies · 2817 views
9 years ago

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.

9 years ago Solution

I ended up using:

TWIG
{{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"

👍 1

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by FrViPofm, 4 weeks ago
4 470 2 weeks ago
Themes & Styling · by johan thomas, 5 years ago
1 799 3 weeks ago
Themes & Styling · by stuart young, 2 months ago
3 656 2 months ago
Themes & Styling · by Sebadamus, 3 months ago
5 678 2 months ago
Themes & Styling · by martynfoster735, 3 months ago
1 640 3 months ago