Then the system will automatically url_encode the Contact.f_FirstName variable, so that “Jean-Stéphane” will come out as “Jean-StÃ©phane” more or less (i.e. the “é”, url_encoded for utf-8). This is the default behavior and is, obviously, absolutely necessary otherwise “all hell would break loose” when passing parameters.
Now, other times, you have fun stuff like “a variable that contains a complete path”. Here, it gets interesting. The actual question is: What do you actually want to do with that variable?
Two possible cases:
You want to send that URL as a PARAMETER to a site. A very simple and common case of this is when you want to send the client to a specific page, but actually need to send him to a login screen first, so you need to send him to a link that looks like this:
So imagine that in OFSYS, you have this:
No choice here, f_StatsPage must be url_encoded or the link will break. The default behavior of the Openfield system will make this work.
Now, other times, you actually have a variable that contains an actual path, that you want to redirect to as-is, without any encoding. Let’s assume (as is your case here) that Contact.f_ModelURL contains a full URL you want to redirect to. Obviously, if we encode it, we’ll create a broken link. So we’ve created a special case just for that.
When a link contains only a single personalization statement, i.e. [[=…;]], then the system will go “ok, this guy’s building his own link. Let’s assume he knows what he’s doing, and we’re not going to encode anything”.
That is why your first example works:
This triggers the special rule, and your link is used as-is. When you add the “?” after the personalization statement however, the rule isn’t matched anymore, so the variable is encoded, and your link is broken. So… the simple solution is to make sure your link is limited to a single [[=…;]] statement when it’s a full URL. What’s INSIDE that statement can be a lot more complex however, so let’s say what you wanted to do is this:
This will not work as previously mentioned, but you can still match the special rule by doing this:
<a href=”[[=Contact.f_ModelURL + “?f_FirstName=” + System.Encoding.URL(Contact.f_FirstName, “utf-8”);]]”>
This is a single personalization statement so it matches the rule, and here we manually url_encode the last value for utf-8, so that Jean-Stéphane still comes out as Jean-StÃ©phane. The final link for this will be:
Hope this helps!
Overall rule is:
- · Normal link with injected personalization tags = all parameters will be encoded (utf-8 usually, based on your project’s config)
- · Link made up of nothing but one single personalization tag = nothing is encoded (but that does mean you need to explicitly encode anything that needs to be encoded).