Last active
February 10, 2023 18:01
-
-
Save georgechang/38f11eb8d5d22cfd7247cbce20b83bf5 to your computer and use it in GitHub Desktop.
Revisions
-
georgechang renamed this gist
Feb 9, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
georgechang created this gist
Feb 9, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,144 @@ {{ # Get all pages that are nested under the root # Check if it has a layout (avoids data source object) # Set flag to true. Show everything if no filter is set. # Get page filters. If a section has filters, set taxonomy flag to false. At least one field must match selected filters. Set to true #if we find a matching field. # If the field parsing remains true after checking each field, add the item to an array. # The array takes the item, and the date field parsed to that the date is a single number, year/month/day. # After all field and array parsing is done, sort the array by date. # Loop through the array and render the items. releases = sc_parameter "NumberOfReleases" numberOfReleases = string.to_int(releases) flag = 0 height = sc_parameter "Height" numHeight = string.to_int(height) classParameters = "class=\"press-release-container height-override small-card-height-" + height + "\"" # Press Release Detail resultsTemplateId = '{A5BA4FAC-8B46-469C-9E34-4CB5F17FF27E}' PressReleasePages = sc_follow i_item "Path To Press Release Pages" Query = 'query:' + PressReleasePages.path + "//*[@@templateid='" + resultsTemplateId + "']" itemDivisions = sc_field i_item "Divisions" | string.split '|' itemIndustries = sc_field i_item "Industries" | string.split '|' itemBrands = sc_field i_item "Selling Brands" | string.split '|' itemEcosystems = sc_field i_item "Solutions" | string.split '|' filters = itemIndustries.size + itemDivisions.size + itemBrands.size + itemEcosystems.size; taxFlag = false renderOrderArray = [] }} {{if (o_pagemode.is_experience_editor_editing)}} <div {{classParameters}}> {{for i_child in PressReleasePages.children}} {{if flag < numberOfReleases}} <div class="press-release"> <a href="#"><h2>Test Title, preview or visit published page to view data</h2></a> <p>26 April 2001</p> </div> {{flag = flag + 1}} {{end}} {{end}} </div> {{else}} {{for i_child in (sc_query i_page Query) }} {{languageVersionAvailable = sc_item_languages i_child | string.split ',' | array.contains i_page.language}} {{if !languageVersionAvailable continue }} {{end}} {{if i_child.has_layout && filters > 0}} {{taxFlag = true}} {{childDivisions = sc_field i_child "Divisions" | string.split '|'}} {{if (itemDivisions.size > 0)}} {{taxFlag = false}} {{for division in itemDivisions}} {{if (childDivisions | array.contains division)}} {{ taxFlag = true}} {{break}} {{end}} {{end}} {{end}} {{if !taxFlag continue}} {{end}} {{childIndustries = sc_field i_child "Industries" | string.split '|'}} {{if (itemIndustries.size > 0)}} {{taxFlag = false}} {{for industry in itemIndustries}} {{if (childIndustries | array.contains industry)}} {{ taxFlag = true}} {{break}} {{end}} {{end}} {{end}} {{if !taxFlag continue}} {{end}} {{childBrands = sc_field i_child "Selling Brands" | string.split '|'}} {{if (itemBrands.size > 0)}} {{taxFlag = false}} {{for brands in itemBrands}} {{if (childBrands | array.contains brands)}} {{ taxFlag = true}} {{break}} {{end}} {{end}} {{end}} {{if !taxFlag continue}} {{end}} {{childEcosystems = sc_field i_child "Solutions" | string.split '|'}} {{if (itemEcosystems.size > 0)}} {{taxFlag = false}} {{for ecosystem in itemEcosystems}} {{if (childEcosystems | array.contains ecosystem)}} {{ taxFlag = true}} {{break}} {{end}} {{end}} {{end}} {{if !taxFlag continue}} {{end}} {{if taxFlag}} {{date.format = '%F%k%M'}} {{itemDate = sc_field i_child 'Publication Date' | date.parse | string.remove '-' }} {{renderOrderArray = renderOrderArray | array.add {item: i_child, date: itemDate } }} {{end}} {{else}} {{if i_child.has_layout}} {{date.format = '%F%k%M'}} {{itemDate = sc_field i_child 'Publication Date' | date.parse | string.remove '-' }} {{renderOrderArray = renderOrderArray | array.add {item: i_child, date: itemDate } }} {{end}} {{end}} {{ end }} {{renderOrderArray = renderOrderArray | array.sort "date" | array.reverse}} <div {{classParameters}}> {{date.format = date.default_format}} {{flag = 0}} {{for item in renderOrderArray}} {{childItem = item.item}} {{if flag < numberOfReleases}} <div class="press-release"> <a href="{{sc_link childItem}}"><h2>{{sc_field childItem "Title"}}</h2></a> <p>{{sc_field childItem 'Publication Date'|date.parse}}</p> </div> {{flag = flag + 1}} {{end}} {{end}} </div> {{end}}