Background Image Paths in Velocity Format
Hi,
I am having issues setting the correct path to apply a background
image to a style attribute within a velocity. It doesn't like it
when I using the [system-asset] tag within the script. What should
I do to correct this?
#if( 'Secondary' == $news_list_header_style )
#set( $class = 'tier-secondary-header' )
#if( 'Yellow' == $news_list_secondary_nav_style )
#set( $background_image = 'img-t1-secondary-news.png' )
#elseif( 'Blue' == $news_list_secondary_nav_style )
#set( $background_image = 'img-t1-secondary-about.png' )
#elseif( 'Pink' == $news_list_secondary_nav_style )
#set( $background_image = 'img-t1-secondary-events.png' )
#else
#set( $background_image = 'img-t1-secondary-utility.png' )
#end
<div class="tier-secondary-header" style="background-image: url([system-asset]/assets/images/${background_image}[/system-asset]);">
<div class="tier-secondary-header-holder">
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="tier-secondary-header-content">
<h1 class="tier-secondary-header-title">$news_list_title</h1>
<div class="tier-secondary-header-text">$news_list_subtitle</div>
</div>
</div>
</div>
</div>
</div>
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
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
1 Posted by Wing Ming Chan on 18 Aug, 2016 02:49 PM
Hi Steve,
Try the following:
There are two things you need to pay attention to:
You may need to use the
img
element to force the image to show up and cached. This is actually a good test for the path and[system-asset]
.You may want to store the variables
$s_system_asset
and$e_system_asset
in a global format that can be reused.Wing