Learn step by step how we can create a SharePoint quote of the day web part using Rest API and Bootstrap in SharePoint Online/2016/2013. In this article, I explain how to create a president Quotes Web part in SharePoint Online using Rest API and bootstrap.
We will use here client-side technologies like SharePoint Rest API, Bootstrap, CSS, etc. which we will add inside a script editor or content editor web part in SharePoint Online/2013/2016.
SharePoint quote of the day web part
Here we will save the quote details in a SharePoint list. In my SharePoint Online site, I have created a PresidentMessage list which has few columns like:
- Title
- Description
- Image to Display
- Status
The SharePoint list looks like below, which has one record also.
Now, go to your web part page where you want SharePoint quote of the day web part should appear. Edit the web part page and add a script editor web part.
In the Script editor web part add the below code.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<style>
.centered {
text-align: center;
width: 400px;
}
h2 {
font-family: "Times New Roman", Times, serif;
}
</style>
<script type="text/javascript">
jQuery(document).ready(function () {
var site = "https://pikasha12.sharepoint.com/sites/DLH/";
jQuery.ajax({
url: site + "_api/web/lists/getByTitle('PresidentMessage')/items?$select=Description,Image_x0020_to_x0020_Display,Author/Title&$expand=Author/Title&$filter=Status eq 'Active'&$top=1&$orderby=Created",
type: "GET",
headers: { "Accept": "application/json;odata=verbose" },
success: function (data) {
//script to build UI HERE
var slidInd = "";
jQuery.each(data.d.results, function (index, value) {
slidInd = '<img src="' + value.Image_x0020_to_x0020_Display.Url + '"/><h2>' + value.Description + ' </h2><h3>' + value.Author.Title + ' </h3>';
});
jQuery(".centered").append(slidInd);
getData();
},
error: function (data) {
//output error HERE
alert(data.statusText);
}
});
});
</script>
<div class="container-fluid">
<div class="panel-heading">
<h3 class="panel-title">CEO Message</h3>
</div>
<div>
<div class="centered">
</div>
</div>
</div>
Once you Save the code you can see the SharePoint quotes of the day web part will appear like below:
You may like following SharePoint tutorials:
You may like following SharePoint tutorials:
- Google Pie Chart in SharePoint Online (Step by Step tutorial)
- SharePoint CSS and JavaScript Examples
- Change default list view style using CSS in SharePoint Online/2016/2013
- 3 Different ways to Change Site Collection URL in SharePoint 2013/2016 using PowerShell
- Left Navigation or Quick Launch Customization or Branding using CSS in SharePoint Online/2013/2016
- Get Current User Details Using JavaScript Object Model (jsom) and jQuery in SharePoint2013/2016/Online
- Get Middle East prayer timing using JavaScript Code
- Display Task List data in a table using SharePoint REST API and filter by status column
- Get current weather using JavaScript in SharePoint Online/2013/2016
- Change language settings SharePoint online
- Add Google ReCaptcha in SharePoint Online or SharePoint 2013/2016/2019 (Step by Step tutorial)
- How to get documents from document library in SharePoint using Rest API
Hope you learn how we can create SharePoint Quote of the day web part using Rest API and Bootstrap in SharePoint Online/2013/2016.
Rajkiran is currently working as a SharePoint Consultant in India . Rajkiran having 7+ years of experience in Microsoft Technologies such as SharePoint 2019/2016/2013/2010, MOSS 2007,WSS 3.0, Migration, Asp.Net, C#.Net, Sql Server, Ajax, jQuery etc.He is C#Corner MVP (2 Times).