Displaying messages from the server on system pages is usually handled within a reusable script. This script can be named anything, but it's a strong convention within StoreFront themes to use the name errors.vm
. UltraCart recommends staying with that convention to aid support efforts should you ever need help troubleshooting a theme.
Listed below is a sample from the original StoreFront theme. Your theme may style the markup differently, but the process will remain the same:
- if there are any errors, then
- iterate through the errors array
- display them appropriately depending on whether the error has already been html escaped or not
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
## these two comments at the top aid code editors to provide syntax check and intellisense.
## they're not required, but leaving them might help if UltraCart support becomes involved.
#* @vtlvariable name="i18n" type="com.bpsinfo.storefront.tobjects.I18nWriter" *#
#* @vtlvariable name="formSupport" type="com.bpsinfo.storefront.tobjects.FormSupport" *#
## $formSupport is a top level variable accessible by all system screens (non-catalog)
#if($formSupport.errors && $formSupport.errors.size() > 0)
<div class="row">
<div class="columns small-full">
<div class="alert error text-left no-margin-top no-margin-bottom">
#foreach($error in $formSupport.errors)
#if($error.alreadyEscaped)$!error.message#{else}$i18n.escape($error.message)#{end}<br>
#end
</div>
</div>
</div>
#end ##if-errors.size() > 0 |