## Productcard heading and slogan ## OFISMAL003-tuotekortti ## OFINAYT014 Tuotekortti - tuotteen nimi ja slogan ## COMMENTED BECAUSE THIS IS UNNECESSARY AFTER BRAND CHANGE! ##
## if ($validator.isNotNull($tuotekortti_tuotenimi.data)) ##

$tuotekortti_tuotenimi.getData()

###end ## if ($validator.isNotNull($tuotekortti_slogan.data)) ##

$tuotekortti_slogan.getData()

## end ##
##
Virhe tapahtui prosessoidessa esitysmallia.
The following has evaluated to null or missing:
==> sisalto2.ohjauslinkki2  [in template "10157#10197#11112" at line 63, column 24]

----
Tip: It's the step after the last dot that caused this error, not those before it.
----
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: #assign results = productDescriptions...  [in template "10157#10197#11112" in function "getProductDescriptions" at line 61, column 3]
----
1<#-- inserted during deployment/ --><#noparse>
 
2<script data-r="webcontent-template-js/op-fi-ofinayt-015" src="/documents/10197/933601379/requirejs-loader.js/7f190522-a0f0-9857-7338-7d1ab48da3a3?version=7.0&c=de47a0f3a959d0f1d910d74435489f74e0994391a23dcecd1d8bbe5436da704f"></script>
 
3</#noparse><#-- /inserted during deployment -->
 
4
 
5<#-- generated with dev-tools/structure-parser.html and added some functionalities -->
 
6<#-- Structure: Tuotekortti-OFISMAL003 -->
 
7<#-- Template: Tuotekortti-OFINAYT015-tuote-esittely-ja-suosittelu -->    
 
8 
 
9<#assign dlService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLFileEntryLocalService")>
 
10<#assign unescapeHelper = serviceLocator.findService("fi.op.lrdxp.extensions.custom.service.api.UnescapeHelper")>
 
11
 
12<#function getFileEntry liferayDocumentUrl>
 
13  <#-- example url: /documents/257828/1263918/Corporate+Gold+kortin+k%C3%A4ytt%C3%B6.jpg/3c172be2-6749-4c73-af5b-14db3372bac7?t=1486452487370 -->
 
14  <#assign fileParts = liferayDocumentUrl?split("/")>
 
15  <#assign groupIdIndex = fileParts?size - 4>
 
16  <#assign groupId = fileParts[groupIdIndex]?number>
 
17  <#assign uuid = fileParts?last?split("?")?first?trim>
 
18  <#return dlService.getFileEntryByUuidAndGroupId(uuid, groupId)>
 
19</#function>
 
20
 
21<#function getStructureValue dataType value>
 
22  <#if dataType == "boolean">
 
23    <#assign result = getterUtil.getBoolean(value)>
 
24  <#elseif dataType == "date">
 
25    <#attempt>
 
26      <#assign result = (value?has_content && value?trim != "")?then(dateUtil.parseDate("yyyy-MM-dd", value, locale), "")>
 
27    <#recover>
 
28      <#return {}>
 
29    </#attempt>
 
30  <#elseif dataType == "double">
 
31    <#assign result = getterUtil.getDouble(value)>
 
32  <#elseif dataType == "integer">
 
33    <#assign result = getterUtil.getInteger(value)>
 
34  <#elseif dataType == "number">
 
35    <#assign result = getterUtil.getNumber(value)>
 
36  <#else>
 
37    <#-- document-library, html, link-to-page, string -->
 
38    <#assign result = value>
 
39  </#if>
 
40  <#return { "v": result }>
 
41</#function>
 
42
 
43<#function getSelectValue optionsMap field>
 
44  <#assign key = "">
 
45  <#if field?has_content>
 
46    <#assign selectedField = field.getData()>
 
47    <#if selectedField?has_content && selectedField?trim != "">
 
48      <#assign key = selectedField>
 
49    <#else>
 
50      <#assign opts = field.getOptions()>
 
51      <#if opts?has_content && opts?is_sequence>
 
52        <#assign key = opts[0]>
 
53      </#if>
 
54    </#if>
 
55  </#if>
 
56  <#return (key?has_content && (optionsMap[key])??)?then({ "v": optionsMap[key] }, {})>
 
57</#function>
 
58
 
59<#function getProductDescriptions productDescriptions>
 
60  <#assign results = productDescriptions?map(sisalto2 -> {
 
61    "html" : ({"v": sisalto2.getData()!""}),
 
62    "links" : getLinks(sisalto2.ohjauslinkki2.getSiblings())
 
63  })>
 
64  <#return results>
 
65</#function>
 
66
 
67<#function getLinks links>
 
68  <#assign results = links?map(link -> {
 
69    "label" :  ({"v": link.getData()!""}),
 
70    "type" : getSelectValue({"value 1":"internal","value 2":"site-ext","value 3":"portal-ext","value 4":"aspa-popup","value 5":"attachment","value 6":"terms-attachment"}, (link.linkkityyppi2)!{}),
 
71    "url" : ({
 
72      "internal" : ({"v" : link.sivusto_linkki2.getFriendlyUrl()!""}),
 
73      "external" : ({"v" : link.url2.getData()!""}),
 
74      "attachment" : {
 
75          "url" : ({"v" : link.liitelinkki2.getData()!""}),
 
76          "ext" : ((link.liitelinkki2.getData())??)?then(
 
77          ((getFileEntry(link.liitelinkki2.getData()).getExtension())??)?then(
 
78            getStructureValue("string",getFileEntry(link.liitelinkki2.getData()).getExtension()),
 
79            {}
 
80          ),
 
81          {}
 
82        )
 
83      }
 
84    })
 
85  })>
 
86  <#return results>
 
87</#function>
 
88
 
89<#assign props = {
 
90  "productName": ((tuotekortti_tuotenimi.getData())??)?then(getStructureValue("string",tuotekortti_tuotenimi.getData()),{}),
 
91  "slogan": ((tuotekortti_slogan.getData())??)?then(getStructureValue("string",tuotekortti_slogan.getData()),{}),
 
92  "campaign": {
 
93    "hasCampaign": ((tuotekortti_kampanja.getData())??)?then(getStructureValue("boolean",tuotekortti_kampanja.getData()),{}),
 
94    "text": ((tuotekortti_kampanja_teksti.getData())??)?then(getStructureValue("string",tuotekortti_kampanja_teksti.getData()),{}),
 
95    "description": ((tuotekortti_kampanja_kuvaus.getData())??)?then(getStructureValue("string",tuotekortti_kampanja_kuvaus.getData()),{}),
 
96    "img": {
 
97        "url": ((tuotekortti_kampanjakuva_iso.getData())??)?then(getStructureValue("document-library",tuotekortti_kampanjakuva_iso.getData()),{}),
 
98        "desc": ((tuotekortti_kampanjakuva_iso_teksti.getData())??)?then(getStructureValue("string",tuotekortti_kampanjakuva_iso_teksti.getData()),{})
 
99    },
 
100    "startDate": ((tuotekortti_kampanja_alkupvm.getData())??)?then(getStructureValue("date",tuotekortti_kampanja_alkupvm.getData()),{}),
 
101    "endDate": ((tuotekortti_kampanja_loppupvm.getData())??)?then(getStructureValue("date",tuotekortti_kampanja_loppupvm.getData()),{}) 
 
102  },
 
103  "htmlText": ((tuotekortti_html_teksti_1.getData())??)?then(getStructureValue("html",tuotekortti_html_teksti_1.getData()),{}),
 
104  "productDescriptions": ((tuoteesittely2.getData())??)?then(getProductDescriptions(tuoteesittely2.getSiblings()),{}),
 
105  "htmlText2": ((tuotekortti_html_teksti_2.getData())??)?then(getStructureValue("html",tuotekortti_html_teksti_2.getData()),{}),
 
106  "referee": ((tuotekortti_suosittelija.getData())??)?then(getStructureValue("string",tuotekortti_suosittelija.getData()),{}),
 
107  "refereeTitle": ((tuotekortti_suosittelija_titteli.getData())??)?then(getStructureValue("string",tuotekortti_suosittelija_titteli.getData()),{}),
 
108  "contentId": .vars['reserved-article-id'].data!"",
 
109  "contentName": .vars['reserved-article-title'].data!""
 
110}>
 
111
 
112<op-fi-ofinayt-015-df996a9d9483af5a4373bbc47ba2cf1aee2dc6bbb3dfa7a42807fb99ea504fc8 props="${unescapeHelper.unescape(jsonFactoryUtil.looseSerializeDeep(props))?html}"></op-fi-ofinayt-015-df996a9d9483af5a4373bbc47ba2cf1aee2dc6bbb3dfa7a42807fb99ea504fc8>