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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Cant get full url with params and queries from uri.url

Started by tomtomd 9 years ago · 2 replies · 3411 views
9 years ago

Hi everyone,

I'm trying to create a twig template that has a back button in it, so the user can jump back to the previous overview page. The content is handled by ajax.
In the overview page I'm creating a link/url in twig with a param 'back' which holds the current url including params and queries. When I'm on page

e.g. /projects?c=new&p=2

the href of the link to the next page with the button in it becomes:

TWIG
{% set linkUrl = page.url ~ '/back:' ~ uri.url(false) %}
<a href={{ linkUrl }}>Go to page</a>

Now in the next page I'm creating the back button which gets its href url by

TWIG
{{ uri.param(back) }}

which was added to the new url.

My problem is that I can't get the full url including all params and queries inside the overview page. Instead im just getting the url without them. So I can pass the param to the next page but without its queries and params, causing the user to loose his last page or category he was browsing. Using Ajax is not part of the problem, as I get no queries in the url as well, when visiting the page directly.

Can someone please tell me what I'm missing here? Thanks!

9 years ago

Oh well thats it :D thanks for the quick response! I had to build it with:

TWIG
{% set url = page.url ~ '?back=' ~ uri.url(false) ~ '?' ~ uri.query %}

I thought uri.url gets the full url including queries and params. The documentation says:

This returns the full URL with or without the host.

TXT
(e.g. uri.url(false) = grav/section/category/page/param:foo?query=bar)

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 195 2 months ago
Themes & Styling · by Ian, 2 months ago
3 91 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 451 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 45 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 125 3 months ago