How to reference a variable system asset ?

jperreault's Avatar

jperreault

15 Oct, 2012 07:52 PM

Hi,

I've been tasked with upgrading Cascade Server to version 7. Some of our Velocity from 6.8 is now broken.

Specifically, this is how our scripts set a variable background image:
- check what folder you are in, and set the the background image to the "folder-name.jpg" if there is a parent folder.

##DETERMINE WHAT FOLDER YOU ARE IN
 #set ($thepath = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/path"))
 #set ($folders = $thepath.value.split("/"))
 #set ($background="")
 #set ($folderList = [])
     #foreach ($folder in $folders)
         #set ($tmp = $folderList.add($folder))
     #end ##END FOREACH FOLDER
     #if ($folderList.size()>2)
         #set ($parentFolder ="")
         #set ($parentFolder = $folderList.get(1))
         #set ($background = $parentFolder+".jpg")
         #set ($departmentFolder ="")
         #set ($departmentFolder = $folderList.get(2))
     #end ##END IF FOLDER SIZE
 ## DISPLAY CUSTOM BACKGROUND IMAGE
 <style type="text/css" media="all">
     body {background: url("[system-asset:local]site://langara.bc.ca/_files/images/default-background/$background[/system-asset:local]") 974px 0px;}
 </style>

In version 7, this throws a Velocity error just after "..../default-background/$background[/system-asset:local] "
Velocity content invalid: Lexical error, Encountered: "/" (47), after : "" at unset[line 22, column 114]

I know it's wierd, but how should I reference a variable system asset like this ?

Thanks,

Jeff

  1. 1 Posted by Ryan Griffith on 15 Oct, 2012 08:47 PM

    Ryan Griffith's Avatar

    It definitely seems as though the parser doesn't like the declaration of the background-image path. Try the following and let me know if this works out:

    ##DETERMINE WHAT FOLDER YOU ARE IN
     #set ($thepath = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/path"))
     #set ($folders = $thepath.value.split("/"))
     #set ($background="")
     #set ($folderList = [])
         #foreach ($folder in $folders)
             #set ($tmp = $folderList.add($folder))
         #end ##END FOREACH FOLDER
         #if ($folderList.size()>2)
             #set ($parentFolder ="")
             #set ($parentFolder = $folderList.get(1))
             #set ($background = $parentFolder+".jpg")
             #set ($departmentFolder ="")
             #set ($departmentFolder = $folderList.get(2))
         #end ##END IF FOLDER SIZE
    ## DISPLAY CUSTOM BACKGROUND IMAGE
    #set ($background = "[system-asset:local]site://langara.bc.ca/_files/images/default-background/"+$background+"[/system-asset:local]")
     <style type="text/css" media="all">
         body {background: url("$background") 974px 0px;}
     </style>
    
  2. 2 Posted by jperreault on 15 Oct, 2012 10:30 PM

    jperreault's Avatar

    Hi Ryan,

    Yes, that change passes Velocity syntax and does work as expected.

    Thanks

  3. 3 Posted by Ryan Griffith on 16 Oct, 2012 11:55 AM

    Ryan Griffith's Avatar

    Glad to hear that did the trick.

    Have a great day!

  4. Ryan Griffith closed this discussion on 16 Oct, 2012 11:55 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? 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