Blog Details - Magma HDI
S'ha produït un error mentre es processava la plantilla.
The following has evaluated to null or missing: ==> request.getParameter("blogid") [in template "20100#20136#5625088" at line 12, column 18] ---- Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: blogid = request.getParameter("blogid") [in template "20100#20136#5625088" at line 12, column 9] ----
1<#-- Service Locators -->
2<#assign
3 journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService")
4 journalArticleResourceLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleResourceLocalService")
5 assetEntryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetEntryLocalService")
6/>
7<#assign blogName = "" />
8<div class="container container_exp_details">
9 <#-- Fetching Article by URL title -->
10 <#assign
11 groupId = themeDisplay.getScopeGroupId()
12 blogid = request.getParameter("blogid")
13 article = journalArticleLocalService.fetchArticleByUrlTitle(groupId, blogid)
14 />
15 <#if article??>
16 <#-- Fetch the AssetEntry for the JournalArticle -->
17 <#assign
18 assetEntry = assetEntryLocalService.fetchEntry("com.liferay.journal.model.JournalArticle", article.getResourcePrimKey())
19 />
20 <#if assetEntry??>
21 <#-- Get JournalArticleResource using AssetEntry -->
22 <#assign
23 journalArticleResourceObj = journalArticleResourceLocalService.getJournalArticleResource(assetEntry.getClassPK())
24 currentArticleId = getterUtil.getString(journalArticleResourceObj.getArticleId())
25 journalArticle = journalArticleLocalService.getArticle(groupId, currentArticleId)
26 />
27 <#if journalArticle??>
28 <#-- Extract Content -->
29 <#assign
30 document = saxReaderUtil.read(journalArticle.getContent())
31 fieldNodes = document.selectNodes("/root/dynamic-element")
32 />
33 <#list fieldNodes as fieldNode>
34 <#assign
35 fieldName = fieldNode.valueOf("@field-reference")
36 fieldValue = fieldNode.selectSingleNode("dynamic-content").getText()
37 />
38 <#if fieldName == "BannerImage">
39 <div class="card p-0">
40 <#assign
41 imageUrlStart = fieldValue?index_of("\"url\":\"") + 7
42 imageUrlEnd = fieldValue?index_of("\",", imageUrlStart)
43 />
44 <#if imageUrlStart != -1 && imageUrlEnd != -1>
45 <img src="${fieldValue?substring(imageUrlStart, imageUrlEnd)}" alt="BannerImage" class="img-fluid"/>
46 </#if>
47 </div>
48 <#-- Define function to get ordinal suffix -->
49 <#function getOrdinalSuffix(number)>
50 <#if number % 10 == 1 && number % 100 != 11>
51 <#return "st">
52 <#elseif number % 10 == 2 && number % 100 != 12>
53 <#return "nd">
54 <#elseif number % 10 == 3 && number % 100 != 13>
55 <#return "rd">
56 <#else>
57 <#return "th">
58 </#if>
59 </#function>
60
61 <#-- ... other parts of your code -->
62
63 <#elseif fieldName == "Title">
64 <div class="ex-health-head">
65 <h1 class="h4">
66 <b>${fieldValue}</b>
67 <#assign blogName = fieldValue + " - Magma HDI" />
68 <#elseif fieldName == "DateOfPublish">
69 <#-- Parse the date -->
70 <#assign parsedDate = fieldValue?date("yyyy-MM-dd")>
71 <#-- Format the date -->
72 <span class="gray font_16 thin">
73 ${parsedDate?string("d")}<sup>${getOrdinalSuffix(parsedDate?string("d")?number)}</sup> ${parsedDate?string("MMMM yyyy")}
74 </span>
75 </h1>
76 </div>
77
78 <#elseif fieldName == "Content">
79 <div class="p_40_0 exp-content-details thin">
80 ${fieldValue}
81 </div>
82 </#if>
83 </#list>
84 <#else>
85 Journal article not found.
86 </#if>
87 <#else>
88 Asset entry not found.
89 </#if>
90 <#else>
91 Article with the provided URL title not found.
92 </#if>
93 </div>
94
95<style>
96 .ex-health-head b{
97 border-right: 1px solid gray;
98 padding-right: 20px;
99 }
100</style>
101
102<script type="text/javascript">
103 document.addEventListener("DOMContentLoaded", function() {
104 var blogName = "${htmlUtil.escapeJS(blogName)}";
105 document.title = blogName;
106 });
107</script>