Creating Gallery Widget by Using the Blank Canvas Widget
Was this helpful?
Was this helpful?
If you need a widget that Nosto's UGC hasn't supplied out of the box yet, Blank Canvas allows you to create your widget from scratch. In this guide, we will show you how to create a Gallery widget with Blank Canvas step by step. You can learn more information about the Blank Canvas Widget in the following guide: .
If the widget is enabled in your stack, you will see the extra widget type, Blank Canvas, appear in your Widget creation page.
Just click the Create Widget button to start.
Before you start getting creative with the Blank Canvas you will need to set it up properly to ensure that it all works.
The Selected Filter is the most important setting among them as it involved the data that you can fetch from Stackla.
The following Tile template will be included by the {{>tpl-tile}} syntax above. We will use classnames .g-tile, .g-caption, .g-photo, .g-img to style with CSS in the next section.
To preview the result of HTML template, we need to get data using JavaScript. Click on the fork button on the JavaScript panel, you will get the minimal code needed.
Click on the button "Update Preview", you should see plain stacked images and captions.
All of the CSS rules reside within the iframe, so you don't need to worry about any conflicts with your page. Please make use of the @import directive to import the external CSS stylesheets you need.
Click on button "Update Preview", you should see images aligned in rows.
By applying Freewall plugin to our widget's container(#gallery), we will get a gallery layout. Please note that the cellH (360) is the same as height property in CSS.
Click on the button "Update Preview", you should see now tiles have filled all spaces of each row, but not images. We will fix it on the next step.
We want images to fill each tile as well. So we set images to a background, and make it fill by CSS (background-size: cover). The tag remains but hidden to let Freewall calculate layout by images width.
That's it! Get your code and embed your Gallery Widget!!
Now let's start writing some HTML. Blank Canvas introduces the template engine and the Mustache Partials feature. In the following example, we will use partial template tpl-tile to render tiles objects. The tiles objects must be prepared in the Custom JS Editor - which we will talk about later.
In the above sample code, we created a tile template that will display the image and caption with the id, emoji, message, and image properties. We have provided quite a few Tile properties so that you can assemble your own structure easily. Please check the for more details.
We want photos to fill each row's space, so we'll need some help from Javascript. We will use a library to help us do the job.
After applying all the Layout, Tile, CSS, and JS code by the above code, you should get a Gallery Widget .