Smart Systems
connecting Businesses


Kooboo Http Data Rules

When version 4.3 of Kooboo CMS was released it included the ability for a new type of data rule, the Http Data Rule. I've seen nothing written about this functionality, even no mention in the official documentation. This seems surprising to me as I can see huge potential for this feature in a CMS. So here is a brief overview of what it is. I welcome feedback suggesting imaginative ways to use the functionality.

In Kooboo CMS a Data Rule is a query defined in the UI via a wizard to select some content based on the rule boundaries and any parameters it receives. This rule can be as simple as "Give me the first piece of content of type 'blog'", or far more complicated like "Give me 20 products that are categorised as being 'TV', have sold more than 50 units and their price is greater than 500, sorted by highest average review".

Regardless of the complexity of your data rule, it provides you with a list of one or more items that match it. The data that matches these data rules are then used by your page or view, usually to display to the end user. It is pretty much the standard way in Kooboo CMS of querying for content and putting it on the page output.

With code revision #174 though, support was added for data rules to not just be pulled from the Kooboo CMS persistence provider, but from any data source accessible via HTTP that is able to give a Json/Xml response. Let's take a look at an example.

A data rule can be added to either a page or a view. Quick tip: for performance reasons, if multiple views on a page want to consume the same data then define the data rule once on the page and pass the results to the views. That way the query is only executed once instead of once per view.

From v4.3 onwards, when we go to add a new data rule the first question that we are asked is if the rule is to pull data from the standard / internal content repository, or from an external HTTP source. Obviously for this example we want to choose the second option:

Once HTTP is selected, we need to provide the rule with a name so that we can refer to it in code. The second and most crucial wizard parameter is the URL that is our data source. In my working example these are the only two fields I have used. However the Kooboo team have had the foresight to include configuration parameters allowing me to choose if I am going a GET or a POST, along with the ability to specify a specific content type, form data to be included and even custom http headers can be inserted.

About the only option missing is an authentication method. Given the scope of that requirement though, I'm not surprised that it wasn't included at this time.

The fields that need completing for a HTTP Data Rule.  Only the first two fields are mandatory.

So in my example I am pulling in data from a Picasa feed. That allows me to externally manage an image library and pull into my CMS the data required to display the images.

For clients that require a CMS that is heavily dependent on media, there is an emerging shift towards stand-alone Digital Asset Management providers. This separation of concerns allows businesses to be less strictly tied to individual solutions and instead rely on DAM providers conforming to standard data schemas.

DAM providers often also include, or work hand-in-hand with Content Delivery Network providers to offer globally-localised caching and a rapid response to user requests.

Example HTTP data rule examples to pull images from Picasa.

So with our HTTP data rule defined, how do we use it?

Like standard Kooboo data rules, the resulting data is placed in the MVC ViewBag for access by the view and page. As we are consuming an XML response, and in this example we still want Picasa to serve up the images in question, we convert the XML to HTML that will become part of the page output. The browser can then parse the HTML and request the respective images from the original source.

My sample view looks something like this:

A Razor view that takes the response of the HTTP data rule query and parses it into a HTML gallery.

The result of which, when combine with some CSS rules looks like:

<insert sample result>

With more sources of data becoming available daily on the internet, it is easy to see this technique becoming a key design point for CMS solutions. Taken to the extreme, it would even be possible in theory to use Kooboo CMS but with 100% of the data being pulled in from an external data source.

Consider what other data could be pulled in for usage, combine the sources and for once the potential is probably limited more by our imaginations than the technology:

  • Social media feeds (Twitter, Facebook, Google Plus)
  • News / Weather details
  • RESTFUL services
  • RSS feeds
  • Map / geolocation data