SOLVED

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

Go to solution
Grégoire_Miche2
Level 10

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

Hi all,

I am using the following code:

#set($downloadLink={

  "BPDCS":{

  "title":"BPD Case Study",

  "link":"http://infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-bpd-digitalisation-..."

  },

  "DACS":{

  "title":"Deny All Case Study",

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

  },

    "IVCS":{

  "title":"Infovista Case Study",

  "link":"http://infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-infovista-systeme-i..."

  },

  "EBSCS":{

  "title":"ESSEC Case Study",

  "link":"http://infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-essec-conception-de..."

  },

  "KDSCS":{

  "title":"KDS Case Study",

  "link":"http://infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-kds-nouvelles-prati..."

  }

})

<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

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

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

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)?

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

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

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
Level 10

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

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="http://${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