2

I have a module tag with a param that accepts a string.

{exp:test:foo return_url="{current_url}"}
...
{/exp:test:foo}

In the module method, I get the return_url param using

$return_url      = $this->EE->TMPL->fetch_param('return_url');

The problem is that I get the literal string

{current_url}

As opposed to it being parsed and getting the current url.

Is there a way to solve this? or is this a parse order issue?

4

The issue is parse order. Read the attached pdf.parse order. Turn on the debugger and then view the template in your browser. Scroll down thru the debugger until you find the tag containing {current_url}. You will see that that {current_url} has not been parsed. According to the attached doc, it is not parsed until step 9 - last.

In your module, try

$uri_string = $this->EE->input->server('PATH_INFO') !== FALSE ? $this->EE->input->server('PATH_INFO') : '/'.$this->EE->uri->uri_string();

or

$segments = array_values($this->EE->uri->segment_array());

or

$this->EE->functions->fetch_current_uri()

| improve this answer | |
  • Hmm could assigning it to preload variables work? – developarvin Aug 30 '13 at 0:27
  • If not, is there an alternative way to get the current url? – developarvin Aug 30 '13 at 0:58
  • see updated answer – Lloyd Hill Aug 30 '13 at 1:35
  • Your solution are good. I added the solution that I used that worked for me. – developarvin Aug 30 '13 at 2:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.