Build path dynamically

lauren.fraser's Avatar


17 Jul, 2014 09:15 PM

I'm trying to build an image path dynamically. I'm using the following code in my velocity format:

  <img src="[system-asset]_common/images/providers/${docsFirstName}-${docsLastName}.png[/system-asset]" />

And I get this error when I test the format:
An error occurred: Could not transform with Script format "_internal/formats/provider-listing": Error on line 25: The value of attribute "src" associated with an element type "img" must not contain the '<' character.
You may choose to retry the operation. If the problem persists, please contact a system administrator.
The error has been logged to the system console.

If I take out the dynamic variables, but use the same code, I don't get the error.

  <img src="[system-asset]_common/images/providers/brent-bartgis.png[/system-asset]" />
I'm not sure if it is because I don't have images with all of the names uploaded into Cascade, or if it is something in the way I'm trying to do it.

I've defined the variables I'm using and they are outputting correctly using the EscapeTool.


  1. 1 Posted by Ryan Griffith on 18 Jul, 2014 03:02 PM

    Ryan Griffith's Avatar

    Hi Lauren,

    It sounds like there may be an issue with one, or both, of your variables. When you have a moment, please attach or paste your Format so I can take a closer look.


  2. 2 Posted by lauren.fraser on 18 Jul, 2014 04:05 PM

    lauren.fraser's Avatar

    Here is the format. And the xml

  3. 3 Posted by Ryan Griffith on 18 Jul, 2014 05:39 PM

    Ryan Griffith's Avatar

    Thank you for attaching the Format and XML, Lauren.

    Looking over the Format, I am seeing that you are setting these variables as follows:

    #set ( $docsFirstName = $docInfo.getChild("firstName") ) 
    #set ( $docsLastName = $docInfo.getChild("lastName") )

    This is setting the variables to an XML Element and not a value, so when you attempt to output them within the <img> tag, it's actually going to output something like the following:

    <firstName />]

    So, instead of:

      <img src="[system-asset]_common/images/providers/${docsFirstName}-${docsLastName}.png[/system-asset]" />

    Try the following:

      <img src="[system-asset]_common/images/providers/${_EscapeTool.xml($docsFirstName.value)}-${_EscapeTool.xml($docsLastName.value)}.png[/system-asset]" />

    Please let me know if you have any questions.


  4. 4 Posted by lauren.fraser on 28 Jul, 2014 06:20 PM

    lauren.fraser's Avatar

    Ryan, that worked perfectly. Thanks!

  5. lauren.fraser closed this discussion on 28 Jul, 2014 06:20 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM