For instance, you may want some pages on your site to ave a banner image, but for the banner image to be different on each page, and changeable by the user, without touching any code. To achieve this, you would simply use an image placeholder in your template, and call it "
banner_image" (names must be lowercase letters, numbers and underscores).
Adding a placeholder
If Smartest has not seen this placeholder before, it will notify you you in the page elements tree:
If you click "Enter it now," Smartest will ask you specify what type of files should go there, and give the new placeholder a label:
Now, the user will be able to choose a different image for the
Working with placeholders in templates
The resulting file chosen to define the placeholder will be passed to the template as an instance of a SmartestRenderableAsset object.
If you want to pre-specify the dimensions of a whichever file is chosen to appear in the placeholder, you can do so with a width and height parameter:
<?sm:placeholder name="banner_image" width="800" height="100":?>
Files selected via placeholders can also be accessed via the
$this variable. This is particularly useful if you need to access the file a second time, or want to access some informational aspect of the file, instead of displaying it, e.g.:
Conversely, if you simply want a button in the page preview to replace or edit the file that appears in the placeholder, or a node to appear in the page elements tree, but do not actually want the file to appear where the placeholder tag is placed in the template, you can add a
<?sm:placeholder name="banner_image" display="false":?>
This works quite week in conjunction with the
$this.placeholders.banner_image construction if you want the control and the display of a file in a placeholder to be located separately.