Loading

Kentico Cloud: client side solution

Last year’s we can see a huge shift towards client side solution in the world of web. Development of JavaScript frameworks like Angular JS, React JS allows us to build rich and interactive UI, moving more and more business rules to a client. This change introduces new requirements to a server and highlights a need in lightweight and stateless solutions. One of such solutions is Kentico Cloud – new warehouse for your content. 

Kentico Cloud is platform agnostic content management cloud solution. That means that you could consume it from any platform: mobile native applications, web site, Windows application using any programming language you like.

In one of my previous posts I suggested server side approach for fetching data from Kentico Cloud. In this post, I’m going to focus on retrieving of a content with JavaScript and some JS frameworks.

 

Kentico Cloud API

Kentico Cloud exposes REST API, that provides an interface to get content. It allows getting list of content items or a single item, list of content types or a single content type structure. Basically, we need to send a GET request and specify data/content we want to receive via query parameters in the request URL. We could specify content type of items we are requesting, columns (elements), order of items, how many items to skip and/or take, etc. Kentico Cloud API allows only reading data. All the details are available in the documentation.

 

So, we are going to implement client side (JavaScript) functionality that will grab some content stored in Kentico Cloud. Before we begin here is what we need in order to rich our goal:

  • Kentico Cloud account – there is a free version, that limits the amount of API call, but it is more than enough in our case
  • Create some project in Kentico Cloud
  • Create at least one content type
  • Create a couple of content items
  • Get project ID at Kentico Cloud – we need to include it into request URL
  • Text editor
  • Browser 😊

For this particular sample, we don’t need any server side logic, so we are good to create simple HTML page with some markup and JavaScript functionality that will do the magic.
 

JS Code

Let’s take a look at pure JavaScript function that retrieves content:
 

function loadContent() {

      var xhttp = new XMLHttpRequest();

      xhttp.onreadystatechange = function() {

        if (this.readyState == 4 && this.status == 200) {

            var data = this.response;

            for (var i=0; i<data.items.length;i++){

                document.getElementById("demo").innerHTML += "Name: " + data.items[i].elements.name.value + "<br/>";

                document.getElementById("demo").innerHTML += "Descr: " + data.items[i].elements.description.value + "<br/>";

            }

        }

      };

      xhttp.responseType = 'json';

      xhttp.open("GET", "https://deliver.kenticocloud.com/6dea43b2-30ae-4f99-8da8-c29d0caa3870/items?element.sampletype", true);

      xhttp.send();

    }


See the entire implementation here.

Here is jQuery AJAX call that fetches content:
 

$.ajax({

      url: "https://deliver.kenticocloud.com/projectId/items?element.sampletype",

      method: 'GET',



      success: function(response) {

        var markup = "";

        $.each(response.items, function(i, el) {

          markup += "Name: " + el.elements.name.value + '<br/>';

          markup += "Descr: " + el.elements.description.value + '<br/>';

        });

        $("#demo").html(markup);

      }

    })


See the entire implementation here.

 And the last one is Angular JS code that does, in fact, what two previous do:
 

$scope.dataSvc = $resource('https://deliver.kenticocloud.com/projectId/items?:contenttype&elements=:elements&order=:order&depth=:depth&skip=:skip&limit=:limit', {

    depth: 0,

    skip: 0,

    limit: 100000

  });

See the entire implementation here.

Looks simple, right? Someone might say that there are no doubts that we could consume Kentico Cloud API with JavaScript or JS frameworks. Yes, but let’s take a closer look into the Angular JS implementation: it creates a single resource factory that allows getting any content by specifying appropriate parameter like this:
 


$scope.dataSvc = $resource('https://deliver.kenticocloud.com/projectId/items?:contenttype&elements=:elements&order=:order&depth=:depth&skip=:skip&limit=:limit', {
    depth: 0,
    skip: 0,
    limit: 100000
  });

$scope.loadData = function(params) {

    $scope.dataSvc.get(params

    , function(response) {

      $scope.data = response.items;

    });

  }

  

  $scope.loadAll = function(){

    $scope.loadData({contenttype: 'element.sampletype'});

  }

  

  $scope.loadFirst = function(){

    $scope.loadData({contenttype: 'element.sampletype', limit: 1});

  }

  

  $scope.loadSecond = function(){

    $scope.loadData({contenttype: 'element.sampletype', skip: 1, limit: 1});

  }

  

  $scope.loadName = function(){

    $scope.loadData({contenttype: 'element.sampletype', elements: 'name'});

  }


As you can see I'm calling $scope.LoadData method with different parameters each time to get different results. 

This is the beauty of Kentico Cloud and the main point of this post: it is possible to implement a centralized access point to all the data stored in Kentico Cloud. Genius is simplicity!

 


Comments
Chandigarh Escorts Service
At anything factor you may also see her high-quality independent escorts in Chandigarh that your coronary heart beat might be increment and you may additionally say that the actual blessed messenger key of success. Dressing feeling of her is definitely incredible given that she wears these clothes in which she looks tremendously more provocative and appealing. You can also likewise provide her warm carrying clothes.
9/13/2017 11:29:19 AM

new pc apps
great post visit our blog for latest apps for laptop, desktop working with windows os 8/10/8.1
9/11/2017 3:59:06 PM

Megabuy SEO
Good Information
Thanks for it
<a href="http://fujie.com.vn/may-hut-am-dan-dung">The Best Dehumidifiers</a>
9/6/2017 8:58:38 AM

may lam mat khong khi
good products http://cello.com.vn/
9/5/2017 3:09:19 AM

may lam mat khung khi
good products http://cello.com.vn/
9/5/2017 3:07:31 AM

Patriots vs Chiefs Live Stream
Watch Patriots vs Chiefs Live Stream online free here:

https://www.twitch.tv/videos/170676598
9/5/2017 1:26:58 AM

UFC 215 Live Stream
Watch UFC 215 Live Stream Johnson vs Borg online free here:

https://www.youtube.com/channel/UCpO1_0isxwuWruD1AyIdfNg
9/5/2017 1:14:35 AM

dhruv
Thanks for sharing......
9/2/2017 6:14:21 AM

irina chen
http://www.microbladingoslo.com/microblading-bryn-oslo/
http://www.microbladingoslo.com/sminke-perfekte-oyenbrynstatovering-oslo/
http://www.microbladingoslo.com/lepper-permanent-make-up-oslo/
http://www.microbladingoslo.com/
9/1/2017 8:24:03 AM

thesis writing help
I know this page contains all the meaningful content which I need. I am very lucky as I am always looking positive for such things. I am fond of reading such blogs and search of amazing thing easy to understand what you want to say in this discussion.
8/30/2017 9:27:04 AM

Research Paper Writing Service
You do make an unmistakable point. Being certain with no solid change is lala land considering. Unmistakably, being negative with affected headway to can act consistently beating. Both sound way (grounded truly) and prompting change are depended upon to help the likelihood of good outcomes.
8/28/2017 9:50:58 AM

Dark Knight Bane Coat
I am totally concurred with your choice. These are the most ever-indicate thought. I regard your exertion for posting something like this here. I am flabbergasted to know competently in this way continue proceeding to share more close.
8/24/2017 10:51:31 AM

coursework service UK
I know this page contains all the meaningful content which I need. I am very lucky as I am always looking positive for such things. I am fond of reading such blogs and search of amazing thing easy to understand what you want to say in this discussion.
8/22/2017 11:48:04 AM

Do My Essays
I think you are looking for an embedded database. Apache Derby Embedded and SQLite are best possible choices. You can compare these two and choose whichever best suits your need.
8/22/2017 9:22:43 AM

news9
<a href='https://youtu.be/ywa4SUkpN5o'>WWE SummerSlam 2017 live streaming results, recaps, reactions, videos, more!</a>

<a href='https://youtu.be/uNrNuvATLWw'>Montréal symphonique, un impressionnant hommage musical à la métropole </a>

<a href='https://youtu.be/bvbRqnPBCrM'>How to watch the total solar eclipse online and on TV</a>

<a href='https://youtu.be/DEoqCOsZYE8'>Clemson’s Doc Redman makes big late rally to win US Amateur
</a>

<a href='https://youtu.be/9Tk8klNEtSY'>Victoria Beckham in tears over son Brooklyn leaving for college </a>

<a href='https://youtu.be/1qIKrPSZqkg'>Foo Fighters follow 'Adele' blueprint on return
</a>

<a href='https://youtu.be/07XP5lWiVkk'>Adam Gase offers opportunity to appraise Doug Pederson
</a>

<a href='https://youtu.be/j8zmVJGK_Fc'>Results pour Montréal symphonique, un impressionnant hommage musical à la métropole
</a>

<a href='https://youtu.be/-Ja1DxPJPpc'>Eugenie Bouchard‬, ‪Connecticut Open‬, ‪Lauren Davis‬, ‪Women's Tennis Association
</a>

<a href='https://youtu.be/OPL1awedWeI'>NXT TakeOver Brooklyn III Live Stream Watch Online
</a>

<a href='https://youtu.be/ZKHka03ZMcM'>Shania Twain had all eyes on her for 'Swingin' with My Eyes Closed'
</a>

<a href='https://youtu.be/dR86yTlsqi8 '>Charlotte Crosby and Stephen Bear split up Geordie Shore star confirms she's</a>

<a href='https://youtu.be/7zDceac5ls4'>America's Got Talent Judges Reveal Who Blew Them Away During First Live Show</a>

<a href='https://youtu.be/QlhzO-TZ-h0'>Made In Chelsea's Louise Thompson warns Mimi Bouchard to STAY AWAY from her brother Sam as they get </a>

<a href='https://youtu.be/0krc2Kteu9g'>Here’s What Jennifer Aniston Has To Say About Rachel’s Nipples
</a>

<a href='https://youtu.be/AClyUqzXARk'>Les burgers à 67 ¢ pour une journée cette semaine chez McDo
</a>

<a href='https://youtu.be/laeDrHm9y8s'>Thomas Rhett's Wife Lauren Akins Gives Birth to Baby Girl
</a>

<a href='News 9'>our channel News 9</a>
8/22/2017 8:13:43 AM

namct
I am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job!
8/19/2017 12:45:09 PM

ahtesham khan
THE FASTEST WEBSITE SPEED, PAKISH HOSTING
SIMPLE, EASY, SOLID AND SUPERIOR SERVICES
Fast SSD Upto 20X FASTER than spinning drives, Litespeed and lightning Powered 9X FASTER than Apache CloudLinux, you can rest assured that your website will be fastest, safe and secure with PAKISH HOSTING.
8/16/2017 1:58:11 PM

ahtesham khan
THE FASTEST WEBSITE SPEED, PAKISH HOSTING
SIMPLE, EASY, SOLID AND SUPERIOR SERVICES
Fast SSD Upto 20X FASTER than spinning drives, Litespeed and lightning Powered 9X FASTER than Apache CloudLinux, you can rest assured that your website will be fastest, safe and secure with PAKISH HOSTING.
8/16/2017 1:56:51 PM

edwardcross
Thank you very much for your post, it makes us have more and more discs in our life, So kind for you, I also hope you will make more and more excellent post and let’s more and more talk, thank you very much, dear.
8/4/2017 6:50:26 AM

myhr.cvs.com login
I thank you for the information! I was looking for and could not find. You helped me!
8/3/2017 11:52:31 AM

sumit
very good
7/27/2017 9:45:15 AM

Samual
Very Good way to explain about cloud
7/18/2017 2:31:53 PM

Varsha
Each site require good UI. without targeting user you cannot survive in Virtual world.
7/18/2017 9:20:43 AM

Songspk
informative post. thanks for share it..
7/6/2017 5:34:30 PM

office com help
Microsoft office setup is the software setup file with this setup file you can install on your computer and some of the supported device to use Microsoft office.
7/6/2017 10:07:51 AM

office com setup
Microsoft office has a different version, and the entire version has the different setup file. Some of the version is Office 2013, Office 2016 and Office 365 etc.
7/6/2017 10:06:31 AM

www.norton.com/setup
Norton is one of the most reliable antivirus providers in the market. Norton is delivering top rated protection from mobile devices and computers. Norton has 3 antivirus packages
7/6/2017 10:05:20 AM

hp printer tech support
Printer has become one of the most useful computer hardware devices that allow people to convert computer generated typescript into a physical printed document.
7/6/2017 10:04:15 AM

www.office.com/setup
Well I want you to know that im awesome :p
7/6/2017 10:03:03 AM

NEMA 5-15 to C13 power cords
I’m extremely impressed along with your writing skills as neatly as with the layout for your blog. Is this a paid subject or did you customize it yourself? Anyway stay up the excellent high quality writing, it is uncommon to peer a nice weblog like this one these days..
7/6/2017 9:26:23 AM

Visit this page for more Male Extra
Nice post - Thanks for sharing this kind of post with us. really very great stuff, keep posting...
7/5/2017 11:00:21 AM

C14 to NEMA 5-15 power cords
Buy C14 to Nema 5-15 Power cords in a variety of lengths & colors from Sf Cable. Cord length ranging from 1 ft to 6 ft. Fast shipping, 60 days money back guarantee!
7/1/2017 9:48:34 AM

online Thesis writing
My friend recommended this blog and he was totally right keep up the fantastic work about homework help.
6/30/2017 8:31:47 AM

Help With C# Programming Homework
They are not able to finish the writing assignments on time. For some students, writing any writing assignments is able to waste their time.
6/30/2017 8:04:13 AM

Help With C# Programming Homework
This is really a great stuff for sharing. Thanks for sharing.
6/30/2017 7:57:49 AM

Make him desire you
I was taking a gander at some of your posts on this site and I consider this site is truly informational! Keep setting up..
6/22/2017 10:31:34 AM

seo module for magento
You have a real ability for writing unique content. I like how you think and the way you represent your views in this article. I agree with your way of thinking. Thank you for sharing.
6/22/2017 8:12:34 AM

custom essay writing service
This post gives truly quality information. I'm definitely going to look into it. Really very useful tips are provided here. Thank you so much
6/22/2017 7:29:46 AM

Sexual questions to ask a girl
You actually make it look so easy with your performance but I find this matter to be actually something which I think I would never comprehend. It seems too complicated and extremely broad for me. I'm looking forward for your next post, I’ll try to get the hang of it!
6/21/2017 1:50:03 PM

US Open
https://openusgolf.com/ US open golf, US open 2017, watch U.S. Open Golf live stream.
6/13/2017 6:58:23 PM

omega replique
hello!! This is a good selling high-end watch site <a href="http://www.swiss-replica.co.uk/category/omega/"> omega replique</a>
6/13/2017 9:49:22 AM

buy essay service
We have a dedicated team eager to ease your academic essay writing burden. Hand over your complex essay writing to Go Paper Writer to buy the best services.
6/12/2017 4:36:42 AM

Belmont Stakes
Belmont Stakes 2017 post positions, odds & more. The 2017 Belmont Stakes will be the 149th running of the Belmont Stakes at Belmont Park.
6/9/2017 9:28:20 AM

testing
testing
6/9/2017 5:57:16 AM

ICC Champions Trophy
The ICC Champions Trophy is a one day international cricket tournament organised by the International Cricket Council, second in importance only to the Cricket World Cup.
6/6/2017 10:44:31 AM

ANDIN
Hi
Thanks for sharing amazing and informative blog.
for more details <a href="www.andin.in">visit here</a>
6/2/2017 8:18:55 AM

Logo Design Firm
Cloud Storage is the best methodology so far. I have been thinking to improve my site speed by uploading all the visual content including images, videos, and icons that take make a site slower. Our site is now a bit slower but I am sure with the help of cloud storage it will be omptimized.
5/30/2017 7:06:25 AM

Marketing Eye Global
Keep up the good work! Well defined.
5/23/2017 11:59:54 AM

wp theme
HI.

Nice post With Good Templates.
I Liked Your Website Its Very Helpfull To Me.
And Also Very Impressives Site For Me.
And Very Helpfull For Me In Future And Also Likes Urs wpthemesfree.website best wordpress themes.


THANKS.
5/23/2017 10:40:41 AM

best essay writing service
Thanks for sharing in detail. Your blog is an inspiration! Apart of really useful tips, it's just really ! This post will be effectively Just about everything looks good displayed.
5/20/2017 2:32:48 PM

Captain Boomerang Satin Jacket
I'm not a daily visitor of this site, but yes I was going through here and saw your post. I must say you have done a great job and this is one of the best posts. Thank you for spreading awareness.
<a href="http://www.saleonleather.com/product/captain-boomerang-jai-courtney-satin-jacket"> Captain Boomerang Satin Jacket </a>
5/19/2017 10:18:26 AM

Custom essay writing service
I know this page contains all the meaningful content which I need. I am very lucky as I am always looking positive for such things. I am fond of reading such blogs and search of amazing thing easy to understand what you want to say in this discussion. Thanks a lot for sharing.
5/18/2017 6:18:43 AM

amit Kumar
Amazing post, I will follow these instructions.
Keep up the good work!
5/17/2017 8:39:12 AM

Profile Essay-Essay Tiger
This is the excellence of Kentico Cloud and the primary purpose of this post: it is conceivable to execute an incorporated get to indicate every one of the information put away in Kentico Cloud. Virtuoso is effortlessness!
5/7/2017 12:41:18 PM

 Security code