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 errorsname info_messages.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 errorsany messages, then
- iterate through the errorsmessages array
- display them appropriately depending on whether the error has already been html escaped or notthe message
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.infoMessages.size() > 0) #foreach($msg in $formSupport.infoMessages) <div class="row no-margin-top"> <div class="columns small-full"> <div class="alert error text-left no-margin-top no-margin-bottominfo"> #foreach($error in $formSupport.errors) #if($error.alreadyEscaped)$!error.message#{else}$i18n.escape($error.message)#{end}<br> <div class="message">$!msg</div> #end</div> </div> </div> </div>#end #end ##if-errors.size() > 0 |