How to use Filter and search in a Widget
Last updated
Was this helpful?
Last updated
Was this helpful?
When Stackla widgets are shown, often a custom menu will be built. The menu will drive the Filter-changing in the widget and often perform other functions too, not necessarily related to Stackla.
In this guide, we will build a case where we can trigger the widget filter by clicking on a menu.
In your Stack, the name Tile is given to a piece of content that has been saved and made available for moderation. It could be a Tweet, an Instagram photo or a YouTube video, amongst others. It could also be a user-generated post to your photo competition.
A Stackla Widget will be created to demonstrate the use of the to switch the filters being displayed.
Stackla Filters drive the content being displayed in the Widget, so they are a key resource used for the menu. The will be used to grab them from
The is will be used to talk to the Widget on the site and get it to switch the Filter being displayed.
In this example we will need to do the following:
Configure Filters & Tags
Enable 'Allow Filter Tags to be overwritten'
Enable 'Enable Text Search'
Create an application to grab the Filter data from Stackla
For this example, we will have some filters to choose from: Latest, Twitter and Instagram. Remove the other Filters, or if you're starting from scratch, create them so that they sort by Latest, with Twitter and Instagram filtering by the Twitter and Instagram networks respectively.
To simplify the example, we will create a simple HTML page and will have clickable filters and tags listing.
Lets add the widget embed code to the page.
To see this example work, we will need to add this. This widgetId will be use to target selected widget.
Let's add clickable filters listing, you will notice the filter-id are attached to the listing, it will be used to do the javascript filtering.
note: don't forget to change the filter-id to your filter-id.
This is how we are going to drive the clickable filters listing. We call the Stackla.WidgetManager class to apply the selected filtering.
Let's build the keyword input form and add JavaScript to it.
This was a very basic example to demonstrate some use of the Widgets Filtering on the same page. You can expand this example to:
Build a better menu for switching
Use dynamic generated filters for flexibility
Use keyword validation
You will need to request from to enable the 'Text Search' option in your Stack. By default, this feature is off.