Some ADT examples for Liferay 7.1
Last active
March 7, 2019 14:15
-
-
Save jverweijL/d994f26e27f75bf240dc67855edff905 to your computer and use it in GitHub Desktop.
Some samples to show how you can use ADT's in Liferay (tested with 7.1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#assign companyId = themeDisplay.getCompanyId()/> | |
<#assign groupId = themeDisplay.getScopeGroupId()/> | |
<#assign userId = themeDisplay.getRealUserId() /> | |
<#assign locale = themeDisplay.getLocale() /> | |
<#assign ddmService = serviceLocator.findService('com.liferay.dynamic.data.mapping.service.DDMContentLocalService') /> | |
<#assign contents = ddmService.getContents(groupId) /> | |
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | |
<script type="text/javascript"> | |
google.charts.load('current', {packages:['corechart']}); | |
google.charts.setOnLoadCallback(drawChart); | |
function drawChart() { | |
var data = google.visualization.arrayToDataTable([ | |
['X', 'systolic', 'diastolic'], | |
<#list contents as content> | |
<#if content.getUserId() == userId > | |
<#assign json = content.getData()?eval> | |
<#if json.fieldValues[0].name == "systolic" && json.fieldValues[1].name == "diastolic" > | |
<#assign systolic = json.fieldValues[0].value.en_US /> | |
<#assign diastolic = json.fieldValues[1].value.en_US /> | |
<#if systolic?has_content && diastolic?has_content> | |
[${content?counter},${json.fieldValues[0].value.en_US},${json.fieldValues[1].value.en_US}], | |
</#if> | |
</#if> | |
</#if> | |
</#list> | |
]); | |
var options = { | |
height: 500, | |
legend: 'none', | |
colors: ['#9575cd', '#33ac71'], | |
pointShape: 'diamond', | |
trendlines: { | |
0: { | |
type: 'linear', | |
pointSize: 1, | |
opacity: 0.6, | |
pointsVisible: false | |
}, | |
1: { | |
type: 'linear', | |
pointSize: 1, | |
opacity: 0.6, | |
pointsVisible: true | |
} | |
} | |
}; | |
var chart = new google.visualization.ScatterChart(document.getElementById('bloodpressure_div')); | |
chart.draw(data, options); | |
} | |
</script> | |
<div id="bloodpressure_div"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#assign companyId = themeDisplay.getCompanyId()/> | |
<#assign groupId = themeDisplay.getScopeGroupId()/> | |
<#assign userId = themeDisplay.getRealUserId() /> | |
<#assign locale = themeDisplay.getLocale() /> | |
<#assign ddmService = serviceLocator.findService('com.liferay.dynamic.data.mapping.service.DDMContentLocalService') /> | |
<#assign contents = ddmService.getContents(groupId) /> | |
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | |
<script type="text/javascript"> | |
google.charts.load('current', {packages:['corechart']}); | |
google.charts.setOnLoadCallback(drawChart); | |
function drawChart() { | |
var data = google.visualization.arrayToDataTable([ | |
['X', 'height', 'weight','bmi'], | |
<#list contents as content> | |
<#if content.getUserId() == userId > | |
<#assign json = content.getData()?eval> | |
<#if json.fieldValues[0].name == "Height" && json.fieldValues[1].name == "Weight" > | |
<#assign height = json.fieldValues[0].value.en_US /> | |
<#assign weight = json.fieldValues[1].value.en_US /> | |
<#if height?has_content && weight?has_content> | |
<#assign bmi = weight?number / ((height?number / 100)*(height?number / 100)) /> | |
[${content?counter},${height},${weight},${bmi}], | |
</#if> | |
</#if> | |
</#if> | |
</#list> | |
]); | |
var options = { | |
height: 500, | |
legend: 'none', | |
colors: ['#9575cd', '#33ac71','#DC143C'], | |
pointShape: 'diamond', | |
series: { | |
0: {targetAxisIndex: 0}, | |
1: {targetAxisIndex: 0}, | |
2: {targetAxisIndex: 1} | |
}, | |
axes: { | |
y: { | |
'weight height': {label: 'Weight/Height'}, | |
'bmi': {label: 'BMI'} | |
} | |
}, | |
vAxes: { | |
// Adds titles to each axis. | |
0: {title: 'Weight (kg) / Height (cm)'}, | |
1: {title: 'BMI'} | |
}, | |
trendlines: { | |
0: { | |
type: 'linear', | |
pointSize: 1, | |
opacity: 0.6, | |
pointsVisible: false | |
}, | |
1: { | |
type: 'linear', | |
pointSize: 1, | |
opacity: 0.6, | |
pointsVisible: true | |
}, | |
2: { | |
type: 'linear', | |
pointSize: 1, | |
opacity: 0.6, | |
pointsVisible: true | |
} | |
} | |
}; | |
var chart = new google.visualization.ScatterChart(document.getElementById('bmi_div')); | |
chart.draw(data, options); | |
} | |
</script> | |
<div id="bmi_div"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some examples | |
Display journal-article with specific template | |
<#assign renderer = curEntry.getAssetRenderer() /> | |
<#assign journalArticle = renderer.getArticle() /> | |
<@liferay_journal["journal-article"] | |
articleId=journalArticle.getArticleId() | |
ddmTemplateKey="203451" | |
groupId=journalArticle.getGroupId() /> | |
Get folder name from asset | |
<#assign foldername = renderer.getAssetObject().getFolder().getName() /> | |
Shorten name for display purposes, will add ... at the end | |
${stringUtil.shorten(foldername,10)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment