Velocity: " makes a reference treated as a literal in an <a> tag | Community
Skip to main content
Grégoire_Miche2
New Participant
March 22, 2017
Solved

Velocity: " makes a reference treated as a literal in an <a> tag

  • March 22, 2017
  • 1 reply
  • 1457 views

Hi all,

I am using the following code:

#set($downloadLink={

  "BPDCS":{

  "title":"BPD Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-bpd-digitalisation-marketing-systeme-information-marketing-commercial.pdf"

  },

  "DACS":{

  "title":"Deny All Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-denyall-marketing-automation.pdf"

  },

    "IVCS":{

  "title":"Infovista Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-infovista-systeme-information-marketing.pdf"

  },

  "EBSCS":{

  "title":"ESSEC Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-essec-conception-deploiement-strategie-acquisition-nurturing.pdf"

  },

  "KDSCS":{

  "title":"KDS Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-kds-nouvelles-pratiques-generation-demande-automatisee.pdf"

  }

})

<ul>

#foreach ($key in $lead.downloadcenter.split("[;]"))

#set ($key = ${key.trim()})

      <li><a href="${downloadLink.get($key).link}" target="_blank" class="mktNoTrack">$downloadLink.get($key).title</a> : $downloadLink.get($key).link</li>

#end

</ul>

The second call to $downloadLink.get($key).link displays the URL OK. But the first one in the href returns an error when we click the link.

For those who want to see it working, try this form: inficiences

Any help is welcome

-Greg

Best answer by SanfordWhiteman

It's not really a reference-as-literal. But it is a bug (not in Velocity but in the way Marketo post-processes VTL output).

Do you see the same when you strip the http​:// from the URL and hard-code it in the <a href=> (as we would outside of Velo)?

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
March 22, 2017

It's not really a reference-as-literal. But it is a bug (not in Velocity but in the way Marketo post-processes VTL output).

Do you see the same when you strip the http​:// from the URL and hard-code it in the <a href=> (as we would outside of Velo)?

Grégoire_Miche2
New Participant
March 22, 2017

Hi Sanford,

Thx this is working.

For a reference, the right code is:

#set($downloadLink={

  "BPDCS":{

  "title":"BPD Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-bpd-digitalisation-marketing-systeme-information-marketing-commercial.pdf"

  },

  "DACS":{

  "title":"Deny All Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-denyall-marketing-automation.pdf"

  },

    "IVCS":{

  "title":"Infovista Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-infovista-systeme-information-marketing.pdf"

  },

  "EBSCS":{

  "title":"ESSEC Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-essec-conception-deploiement-strategie-acquisition-nurturing.pdf"

  },

  "KDSCS":{

  "title":"KDS Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-kds-nouvelles-pratiques-generation-demande-automatisee.pdf"

  }

})

<ul>

#foreach ($key in $lead.downloadcenter.split("[;]"))

#set ($key = ${key.trim()})

      <li><a href="${downloadLink.get($key).link}" target="_blank" class="mktNoTrack">$downloadLink.get($key).title</a> : $downloadLink.get($key).link</li>

#end

</ul>

Useful to be used for a download center together with a unique field displayed in forms as a checkboxes.

-Greg