Sajad Kioumarsi
Sajad Kioumarsi

Reputation: 84

how to get the request URI in zf2 twig?

I want to get the full URI address of the current page in twig page in zf2. if I use url() it will only return back the zend url not the full adress.

Upvotes: 1

Views: 514

Answers (2)

Sajad Kioumarsi
Sajad Kioumarsi

Reputation: 84

The solution on the top is a good solution to have customized global variables in twig for zf2 but to the specific problem I have I found the solution:

{{serverUrl(true)}}

the parameter true was what I was missing to get the full url.

Upvotes: 0

viarnes
viarnes

Reputation: 2048

I'm using a custom framework (similar as Symfony2). The way I handle this kind of things is by creating global twig variables inside the constructor of my controller. Take a look at this ZF2 - Rendering variables from Module.php to twig layout.

Upvotes: 1

Related Questions