Hi Team,
How can we include a script directly in sightly component
Trying to include a script for datalayer directly in a component.
Regards
Ankur
Solved! Go to Solution.
Views
Replies
Total Likes
<sly data-sly-include="yourscript.html" />
This is how you include scripts.
Hi
Adding to what Feike said,
Please have a look at this community article covering many example for HTL (formerly know as Sightly).
Link:-http://blogs.adobe.com/experiencedelivers/experience-management/htl-intro-part-1/
~kautuk
Views
Replies
Total Likes
Views
Replies
Total Likes
Feike Visser wrote...
<sly data-sly-include="yourscript.html" />
This is how you include scripts.
So can we include following script directly in "yourscript.html " directly and use as u specified above-
<script>
var digitalData = $('#digitalData').val();
var date = new Date();
var clientHourOfDay = date.getHours();
var pageVisitJson = JSON.parse('${datalayer.pageVisitAsString}');
var systemHourOfDay = pageVisitJson['hourOfDay'];
var diffHourOfDay = clientHourOfDay - systemHourOfDay;
var days = ['Sunday','Monday','Tu','W','Th','Fry','Satuay'];
var isWeekend = "false";
if (diffHourOfDay >= -2 && diffHourOfDay <= 2) {
digitalData.visit.hourOfDay = clientHourOfDay;
digitalData.visit.dayOfWeek = days[date.getDay()];
if(date.getDay()===6 || date.getDay()===0){isWeekend="true";}
digitalData.visit.isWeekend = isWeekend;
}
</script>
Views
Replies
Total Likes
Yes. Although you will probably need to include the "@context=" where appropriate since you are populating a JS string. You will need to chose the appropriate context scriptstring, unsafe, etc.. that matches what you populating.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Like
Replies
Views
Likes
Replies