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

Get url page via twig

Solved by Claud Rusnac View solution

Started by Claud Rusnac 8 years ago · 2 replies · 2679 views
8 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.

8 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 Sebadamus, 6 days ago
5 148 13 hours ago
Themes & Styling · by martynfoster735, 1 week ago
1 192 1 week ago
Themes & Styling · by Justin Young, 3 weeks ago
1 241 3 weeks ago
Themes & Styling · by Slebeig, 1 month ago
4 375 1 month ago
Themes & Styling · by Pedro M, 3 months ago
4 744 3 months ago