Filters
Filters can edit the value or output of variables. Filters are used on the right side of a variable separated with a pipe "|". Enstore has a couple of filter which are very important for the templates to work properly.
for instance:
[[ value|capfirst ]]
If value is "enstore", the output will be "Enstore".
The Imagelink filter / Displaying product images
Images for products are added in Checkout. When you're looping through a list of products you can display their images by using the following code:
[% for image in product.images %] <img src="[[ image.url|imagelink ]]"> [% endfor %]
The imagelink filter picks the path for you, so you don't have to worry about linking to the right file.
You can scale your images to make thumbnails, or just to make images fit in you design by adding the following code after the image tag, like this:
<img src="[[ product.images.0.url|imagelink ]]?width=100&height=100&crop=1">
You can either use crop=0 or crop=1.
crop=0 which will resize the image to the specified dimensions, which could result in a distortion of the image. It's used when you want to proportionally resize an image without cutting anything off.
crop=1 will scale down the largest side of the image to the specified dimensions and cut off the rest to fit the specified height and width.
The web store allows you to use images for products up to 800kb per image, but not larger!
The Assets Filter / Linking to files in the assets folder
Other images you might want to use, like banners and such, can be put in the assets folder. In this case you'll have to use the asset filter. Like so:
<img src="[[ "banner.gif"|asset ]]" >
The Textile filter
If you want to offer the people using your template the possibility to markup their product descriptions and homepage intros using textile you'll need to use the textile filter. Basically the textile filter tells the template to interpret the value of the variable as textile markup. More on textile
[[ product.description|textile ]]
Striptags filter
In some cases you don't want html tags in variables influencing your design. You can use the striptags filter to strip all HTML tags from text.
[[ product.description|textile|striptags ]]
Truncate Words filter
You can truncate variables by words using this filter.
[[ product.description|truncatewords:"28" ]]
Using filters sequential
You can use multiple filters on one value. For instance, maybe you want to display a product description, interpret the textile characters, then strip away the HTML tags and lastly truncate the text to 28 words.
[[ product.description|textile|striptags|truncatewords:"28" ]]
More Filters
You can find many more filters here: Django Filters