Hi there
I'm trying to dynamically feed a variable into a URL but I'm having trouble. It works just fine in preview mode (which I know isn't the same as a live test) but when I send myself a sample email, it breaks - the URL variable outputs as $MatchingToursDossiers[0] instead of the actual value I need.
Here's the relevant code. Every other bit outputs as expected.
##set the matching tours arrays to be blank (this is our output)
#set ($MatchingTours = [])
#set ($MatchingToursDossiers = [])
##for each dossier that matches one in the Promo Map object, add it to the Matching Tours array.
#foreach ($wish in $DossierArray)
#if ($PromoMap[$wish])
#set ($dummy = $MatchingTours.add($TourDossierMap[$wish]))
#set ($dummy2 = $MatchingToursDossiers.add($wish))
#end
#end
##if no matching tours, print nothing. If one or more matching tours, print the relevant lines. And here's where it breaks down...$MatchingTours[0] outputs the text name just fine, but the $MatchingToursDossiers array doesn't resolve in the URL.
#if ($MatchingTours.size() == 0 )
#elseif ($MatchingTours.size() == 1 )
<tr>
<td align="center" valign="top" bgcolor="#ffffff" class="bodyText" style="padding-top:0;padding-bottom:30px;padding-right:15px;padding-left:15px;border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;color:#000000;font-size: 16px; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; text-align: left; line-height:24px; mso-line-height-rule:exactly;vertical-align:top;text-decoration:none; font-weight:400;"> This might look familiar: <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[0]</a> from your Wish List is part of this sale! What are you waiting for?
</td>
</tr>
#elseif ($MatchingTours.size() == 2 )
<tr>
<td align="center" valign="top" bgcolor="#ffffff" class="bodyText" style="padding-top:0;padding-bottom:30px;padding-right:15px;padding-left:15px;border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;color:#000000;font-size: 16px; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; text-align: left; line-height:24px; mso-line-height-rule:exactly;vertical-align:top;text-decoration:none; font-weight:400;"> These might look familiar: <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[0]</a> and <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[1]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[1]</a> from your Wish List are part of this sale! What are you waiting for?
</td>
</tr>
#elseif ($MatchingTours.size() == 3)
<tr>
<td align="center" valign="top" bgcolor="#ffffff" class="bodyText" style="padding-top:0;padding-bottom:30px;padding-right:15px;padding-left:15px;border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;color:#000000;font-size: 16px; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; text-align: left; line-height:24px; mso-line-height-rule:exactly;vertical-align:top;text-decoration:none; font-weight:400;"> These might look familiar: <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[0]</a>, <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[1]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[1]</a>, and <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[2]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[2]</a>
from your Wish List are part of this sale! What are you waiting for?
</td>
</tr>
#else
<tr>
<td align="center" valign="top" bgcolor="#ffffff" class="bodyText" style="padding-top:0;padding-bottom:30px;padding-right:15px;padding-left:15px;border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;color:#000000;font-size: 16px; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; text-align: left; line-height:24px; mso-line-height-rule:exactly;vertical-align:top;text-decoration:none; font-weight:400;"> These might look familiar: <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[0]</a>, <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[1]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[1]</a>, <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[2]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[2]</a>, and more
from your Wish List are part of this sale! What are you waiting for?
</td>
</tr>
#end
#end
Any ideas as to why this is breaking in this fashion? I've tried using $MatchingToursDossiers.get(0) and $MatchingToursDossiers(0) with no result.
Solved! Go to Solution.
First, try this with formal notation instead as it helps disambiguate tokens within a string:
/trips/${MatchingToursDossiers[0]}/?utm_...
However I wonder if this is indeed the issue, or something more sinister that can happen with multiple links (see this post).
Can you edit with syntax highlighting please?
Hi Sanford
Sorry, I'm not exactly sure what you mean. Do you mean highlighting the code vs the comments? If there's a better way to display this let me know - it doesn't make it easy on the eyes!
Yeah, use the Advanced Editor's Syntax highlighting:
First, try this with formal notation instead as it helps disambiguate tokens within a string:
/trips/${MatchingToursDossiers[0]}/?utm_...
However I wonder if this is indeed the issue, or something more sinister that can happen with multiple links (see this post).
Thanks so much Sanford! That has done the trick. I previously thought I had tested that - but I'm guessing I used ${variable}[0] instead of ${variable[0]} . With the proper notation, this works just fine.
Your trick to show syntax is very useful too, thank you!