Dream. Dare. Do – that is Suyati’s work principle in a nutshell.
If you are a budding ektron developer longing to learn about Ektron’s framework API, you are at the right place! The scope of this blog post is to provide you an introduction to Ektron’s framework API.
In a nutshell, API refers to a library which consists of certain classes, functions properties etc., which can be used in our programs depending on the nature and the requirement in certain way.
When a software maker releases their API to the public, other software developers can make use of it to build their products, thus it actually provides a “software to software” interface, not an user interface.
Now let us look into Ektron’s Framework API.
Framework API is the interface available to the developers to interact with the Ektron’s system objects. Ektron has exposed almost all its features, no kidding, in the workarea through framework API. You can do almost everything you do over there in Ektron workarea programmatically by using framework API, that too with very little coding. This means, Ektron’s framework API provides a doorway to access the data in a controlled manner. The ultimate goal of framework API is to deliver the best developer experience. The framework API was introduced in Ektron 8.0 and it was vastly expanded with the release of Ektron 8.5.
Guiding principles of Framework API
The three guiding principles of Framework API are:
Now, let us look into these aspects in detail.
Simplicity:This refers to the ease for developers to make use of the API, in a plain way the framework API is simple, it’s not rocket science at all!
Consistency:The other important guiding principle of Framework API is consistency. The Framework API is consistent throughout all its classes, namespaces, properties and functions.
Once you use one API, you will come to know how to use another API. It’s something like, If you know how to pull list of contents, you will come to know how to pull list of users.
Discoverability: Many of us don’t use documentations these days! We directly jump into the IDE and start coding (which I hate with all my guts!). This is precisely why having a highly discoverable API is considered among the best practices. The Framework API follows certain patterns, which means if you write the code to pull some contents from workarea, you will be able to guess the code to pull some ektron users. At the end, these three guiding principles ensure that ektron simplifies a developer’s life drastically. Yes! You will be able to build an ektron website pretty quickly, it’s not hard.
Elements of Framework API
Framework API has got three important elements. This includes,
• Framework Managers
• Data Classes
• Criteria Object
Now let us analyze the Framework API elements with a simple example. Imagine you need to pluck apples from an apple tree. In this case the person who is going to perform the action can be treated as “Manager”. And where you are going to perform this action? It’s on an apple tree; it can be treated as “Data Class”. And how you are going to pluck the apple? You will opt some conditions for it, like plucking a raw apple, plucking 5 apples..etc. These conditions can be treated as “Criteria object”.
So we can re write the process of plucking apple as follows,
Manager preforming an action on Data class based in some criteria’s.
This is what we are going to do in our Ektron CMS using Framework API! Pretty simple huh?
Framework Managers: Framework managers are basically responsible for all the CRUD operations. And the managers reside to the following namespace,
And the CRUD operation that we perform in the CMS includes the following:
Think this by considering a content in the CMS, content will have a manager element to perform these CRUD operations on i.e., getting a single content, getting a list of content, adding a new content, updating an existing content, deleting a content..etc.
Data Classes: Every manager is associated with a Data class. Manager performs actions on corresponding data classes.
Data classes resides to the following namespace,
In this way a Content Manager performs actions on Content Data class.
Criteria Object: Criteria object is used to specify the characteristic of actions performed by the Managers. This refers to sorting of results, applying filters..etc.
And criteria object belongs to,
In short Framework API makes use of Managers to perform actions on Data Classes based on Criteria Object.
Write Some Code!
Tired of reading? Come on, let’s write some code,
Create a new content:
So all we need to do is creation of content. And we need a manager to perform the action of creation of content; on corresponding Data Class (well we don’t need criteria here).
What would be the manager for content? I have already mentioned the Framework API is discoverable, so you can guess that. Yes you are right!
It’s ContentManager.And what is the data class for content? Yes, it’s Content Data
Let us instantiate these two classes first,
Now we need to assign some properties to the content, so let us look into the properties of content,
Well, let us go on and assign these properties right away,
Now we can pull the content to the workarea,
Thus we have successfully created content in the workarea through Framework API.
Can we try creating a folder in workarea? (This is going to be fun!)
Guess the manager & data class?
You are right, it’s FolderManger & FolderData. Look into the properties of Folder Data class,
We haven’t used Criteria Object yet. Now let us look into a problem which needs criteria object.
We will try retrieving all the contents from the folder with id ‘76’
As usual we need the manager, and here the data is not a single entity, it’s a list of contents, and we have criteria to pick the contents in the folder with id ‘76’.
Criteria object enables to add filters to the action. For example,
• Get list of content items from a folder
– Published by a particular user, Authored after a specified date..etc
• Sort and Order results
• Set a limit on the number of results returned
• Page through results
• Apply additional Filters and Group using LINQ
So Start playing with framework API, shout out your thoughts here. Happy Coding!