A Use Case Study
Several sections of their website displayed data or assets in a list view and required these queries to be identified ahead of time and with the help of IT.
Yet what the client wanted was to take control on setting the criteria based on which groups of assets were obtained from the CMS.In short, the content authors know exactly how things should appear on the pages, but don’t have the same clarity on which assets should make it on to those pages (as it is driven by market and other factors) ahead of time.
The default approach was, every single time they identified some unique criteria to filter content, they would need a developer to write a module (WebCenter Sites Template) for them to convert criteria into and equivalent WebCenter Sites query. Authors wanted to be able to create them on an as needed basis and without the help of a developer.
Here are some simplified examples of what they needed to be able to do:
- Display press releases published in past 6 months sorted by publish date.
- Show all the countries in which they operate in alphabetically.
- Display products based on a selected category.
- List the latest news on the homepage for a few weeks and then switch and show the latest products released for next few weeks.
Before getting into the details of the solution, let’s briefly evaluate the options available out-of-the-box.
This allows the user to provide raw SQL queries to access data and be fetched from the CMS and can be designed to seamlessly work with the code that renders data on to the webpage. It also however, requires a developer or a DBA’s intervention to setup these queries.
Writing modules for every possible query
This requires to know all possible queries up-front, so it was not even considered.
We needed to build a solution that allowed the customer a way to setup queries from the Contributor UI, but without dealing with the complexities involved in constructing a query. The outcome was a custom attribute editor using jQuery QueryBuilder widget. We pre-populated the editor with all the asset types, subtypes and attributes available in the system in human readable form, making it easier to build the query using this widget.
1. List all articles published in January 2017.
2. List all products belonging to the North America region.
3. List all products belonging to the sugar or rice category.
The result is a simple and intuitive way to create a query. All types, subtypes, attributes and operations are available in dropdowns menus allowing the user to easily setup queries and less prone to error. The attribute editor automatically converts the queries into equivalent asset queries when the page is rendered and passes the asset ids to the rendering code elements.
Beyond these Use Case
While this feature was developed to address a specific use case, using this widget provides many additional advantages.
· Reduces the development time and cost. By essentially decoupling the visual aspect of the content from the logic to obtain it, developers can focus on the former while the content authors work on the later thus reducing the overall development time and cost.
· Increases flexibility and efficiency. Content authors can create any number of modules once complete without the help of a developer.