Portal Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2024 08:17 AM
There is a portal content with type as video content on the employee centre portal. The video has been attached using creating a record in the sn_cd_url_asset table.
Now I want to add one more video to that video content as a carousel if possible or is there any way that we can put time frame that after that particular period the new video should not show on the portal and only the older one should show?
How to achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2024 06:19 PM
Hi @Vaishali 11 ,
As you need the video should only be displayed for a specific time only then the general approach would be to follow the below steps-
Step 1- Add Display Start and Display End Date Fields:
- Add fields like display_start and display_end to the sn_cd_url_asset table.
Step 2 - You need to modify the widget to display the carousel
If you are using a widget to display the video, modify it to incorporate a carousel feature
Try to modify like the below HTML Template
<div id="videoCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div ng-repeat="video in c.data.videos" class="carousel-item" ng-class="{'active': $index === 0}">
<iframe width="560" height="315" ng-src="{{video.url | trustAsResourceUrl}}" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<a class="carousel-control-prev" href="#videoCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#videoCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Step 3 - Modify widget client script:
function($scope, spUtil) {
spUtil.get('your_server_script_to_fetch_videos').then(function(response) {
$scope.data.videos = response.data.result;
});
}
Step 4 - Modify the server script
(function() {
var gr = new GlideRecord('sn_cd_url_asset');
gr.addQuery('type', 'video'); // Adjust based on your requirement
var now = new GlideDateTime();
gr.addQuery('display_start', '<=', now);
gr.addQuery('display_end', '>=', now);
gr.query();
var videos = [];
while (gr.next()) {
videos.push({
url: gr.url.toString(),
title: gr.title.toString()
});
}
data.videos = videos;
})();
In server side script we are validating the start and end date of the video when this should be displayed.
I think this approach should help you in getting the desired output.
If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!
Thanks & Regards,
Sanjay Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2024 12:01 AM
Hi @Community Alums ,
So there is already one existing record in sn_cd_url_asset table where there is a video uploaded using url. So can we upload 2 video links there? If yes how?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2024 02:47 AM
Hi @Vaishali 11 ,
if you look at the script, you need to create the records in sn_cd_url_asset table and type should be video, and videos kver there like 2 or may be three records, ensure type is video, and the script will iterate the records.
var gr = new GlideRecord('sn_cd_url_asset'); gr.addQuery('type', 'video'); // Adjust based on your requirement var now = new GlideDateTime(); gr.addQuery('display_start', '<=', now); gr.addQuery('display_end', '>=', now); gr.query();
Thanks & Regards,
Sanjay Kumar