1

I have a custom field type that I've developed that I'm having a problem with.

If I do something like {field return="http://mysite.com/group/template/entry-url/thanks"} everything parses fine.

I'm using structure on the site too and if I use {field return="{structure:page:url}thanks"} that also works.

But if I try to use a global variable inside like {field return="{current_url}/thanks"}, the replace_tag() method does not get called and I get an output like {field return="http://mysite.com/group/template/entry-url/thanks"}

Even using an embed didn't work, the code below outputs the same as the example above

embed code

{embed="group/.field" entry_id="{entry_id}" return="{current_url}/thanks"}

In field.html

{exp:channel:entries
    disable="categories|pagination|member_data"
    entry_id="{embed:entry_id}"
}
    {field return="{embed:return}"}
{/exp:channel:entries}

I'm assuming this is some weird parse order issue, but I have no idea why it would happen. Is there a way to change when a field is parsed, or some other way to make this work?

1

This is due to an issue with the EE API (it simply doesn't support nested variables within the FT tag parameters). The reason structure works is those tags are parsed early so by the time the channel entries loop run, the variables are parsed and therefor the FT tag parses correctly.

You need to use the following syntax to pass variables that are parsed later. Note, there are definitely other ways to work around this limitation, but this is the easiest fix if you don't need to use the tagdata for anything else.

{field}
    {embed:return}
{/field}
0

Try using $this->EE->TMPL->parse_globals($tagdata) in your fieldtype code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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