Joe Scotto Joe Scotto - 1 year ago 143
Twig Question

Append onto current URL with Twig?

I'm currently making a simple file hosting script using Slim, Twig, and PHP. Right now I'm trying to append onto the current URL using Twig but am not sure how to do this. I've tried

/panel/{{ newURL }}
but it always just redirects me to
. I need to be able to dynamically update this URL.

For example, if I want to go to
I need to be able to append that onto the current URL. Does Twig offer a way to do this? Thanks.

Answer Source

I ended up just passing 'url' => $request->getUri()->getPath() in my view parameters. I think this is a pretty decent method because there are other methods you can call on getUri() to get different results depending on what you want to do.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download