close

Filter

loading table of contents...

Frontend Developer Manual / Version 2401

Table Of Contents

5.7 Referencing a Static Theme Resource in FreeMarker

Blueprint provides the FreeMarker function bp.getLinkToThemeResource(path) that allows creating links to static resources of the Frontend Workspace. A file is referenced by its path which needs to be specified relative to the target directory of the theme (see Section 4.2, “Theme Structure”).

For example, the following snippet of a FreeMarker template creates an HTML img tag pointing to an image located in the theme's target folder at img/logo.jpg:

<img src="${bp.getLinkToThemeResource('img/logo.jpg')}"/>
Note

Note

Do not move the files uploaded by the theme importer to other locations in the content repository. The paths in the FreeMarker templates would be not valid anymore and the website could be broken without even noticing it.

In order to prevent access to resources outside of the theme, the path must not contain descending path segments ("..").

Caution

Caution

bp.getLinkToThemeResource(path) is intended to be used within templates of themes and not within templates of bricks. The provided path contains knowledge about how a theme is build which may vary from theme to theme depending on the adjustments that were made to the build configuration.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.