Content Wrapper template file
Content Wrapper template file
The CWT file is a template. It determines how the Dynamic Content is rendered. It can include references to parameters defined in the Content Wrapper XML file (both the user-input-settings and the template-parameters. To refer to a parameter, specify the name preceded by the dollar sign ($) character.
Like the Content Wrapper XML files, CWT files are stored in the <assets>/content-wrappers directory and are reloaded periodically and the Content Wrappers (XML files and CWT files) are reloaded (by default, every 600 seconds). You can configure the reload interval by editing the COMMERCE/SYSTEM/CONTENTWRAPPERS/reloadInterval setting. If you are testing changes to Content Wrappers and want to see your changes reflected more quickly, decrease the reload interval.
CWT files are rendered using the Velocity engine, but do not have access to any extermal context. It may only reference objects passed to it via the parameters defined in the Content Wrapper XML file.
The following is a sample Content Wrapper template:
<!-- Simple image with alt text and on click action --> <a href="$onClick"><img alt="$altText" border="0" src="$baseDcAssetUrl/$imagePath"/commerce-legacy/></a> <!-- /Simple image with alt text and on click action -->
Try to avoid including a lot of formatting information in the Content Wrapper template. It can interfere with styles and page layout around the Content Wrapper. Likewise, the styles in the containing page may cause the Content Wrapper to not appear as intended. To reduce the need for web developer customization, it is best to make the Content Wrapper template as generic as possible.
Special variables
In addition to the parameters passed from the Content Wrapper XML file, there are two other variables that can be used in Content Wrapper templates:
- $baseUrl, which contains the web application context.
- $baseDcAssetUrl, which contains the web path that resolves to the dynamiccontent asset directory.Note:
When referring to an asset in a subdirectory of dynamiccontent (for example, images or flash), do not include the subdirectory name.