Currently writing this for something at work
It’s nothing too fancy, i just wondered if anyone could tell me if it could be made more efficient?
A mate recommended a hashmap instead but I would like to know other peoples opinion.
Given that it isnt that complex I am hoping that it is readily apparent as to what I am doing.
p.s forgive any structural errors (if any), dont have access to the web server and put it together on the train home…
## initialise stuff
#set ($group = "NotSet")
#set ($grouplink = "NotSet")
#set ($sheetlink = "NotSet")
## array
#set( $siteList = [
["BecclesBungayJournal.d","1uSPcqqCJ5Hg59syRk02roBZv0EGqLXt8hkRPojlPGSI","Norfolk"],
["DerehamTimes.d","1YW8esOO7QVDi7G6IRifead8FV0fjkRXStfqtxxPGYpw","Norfolk"],
["DissMercury.d","1yTvpFomI-1bk26GPs0Flz5zXBDjNMfmht5LyBttG6yk","Norfolk"],
["EasternDailyPress.d","1zQA8L97s4Zzema76uBw5kGVSDICk7EFb3XA53lkGpb0","Norfolk"],
["EveningNews.d","1zQA8L97s4Zzema76uBw5kGVSDICk7EFb3XA53lkGpb0","Norfolk"],
["FakenhamWellsTimes.d","19uQMGoD6H-jO7LNpQFj83Clemk3uhVo5A5YS4NYmKvM","Norfolk"],
["YarmouthMercury.d","1EZj9_bIE_NDc-Lspno40Z0udJCfWK2paixHFg4vNCAw","Norfolk"],
["LowestoftJournal.d", "16wMDbV3sk1FJPXAMb0ecH1VHxAnR9mTnuMTAT40R-zs", "Norfolk"],
["NorthNorfolkNews.d","1A50oTBpzRRenkZoYu3V2P6ZGR0olWGer0SO6y-lYLhs","Norfolk"],
["PinkUn.d","1AjHNRoGDpo-cvusmVPptTjQzZgMRQqLqLuuLCVzxyZI","Norfolk"],
["ThetfordBrandonTimes.d","1M2k0awqsMk8imNHT0NBe5UY0gS5hAKXDVGf3tK_uK1A","Norfolk"],
["WattonSwaffhamTimes.d","19Y5tH-dZ37jpWYZ52xwEXfdBF-HsvbHT-zHtW0nNb_Q","Norfolk"],
["WymondhamAttleboroughMercury.d","1rdTUnkLHYUMa2OGcXng7v929A3LXNf_0fqYn7Dyf4bs","Norfolk"],
["Bury.d","1yFdSBBTvcXu7-_6wJHvS_kgxF7WUzO7gSfqGKH-1GUo","Suffolk"],
["CoastalScene.d","1A5zPCXceyPg5BlRVN037s1TtKD1Efn42tVpL7Zm20eo","Suffolk"],
["EastAnglianDailyTimes.d","1I_9KD4sDtOb1RA5heJGnmlV9uSz4khl_MZMQUzpv4ww","Suffolk"],
["Felixstowe.d","1cTsj3KwEtStCPsaDkjvOLyG2FyesR_Qm7_z068dl2EA","Suffolk"],
["GreenUn.d","1Z7dbl1sq1fDIxbbea5VFsJR1Z3ZAuh9YFWDuyMykyfc","Suffolk"],
["EveningStar.d","1QmoR0mwohSg_KxqyBLQV_CDAsGQ8RMlv65IiuSupMzk","Suffolk"],
["LoveSpeedway.d","15Ql3yxiQ0ggJx7K3XLZQneHIELZagIalJnfEerqCINU","Suffolk"],
["Stowmarket.d","1rKAn6ULBvsFws7ndlnb8lQqOvOTqHbRBWAi3riC64MI","Suffolk"],
["Sudbury.d","1K4H_ACNgsZRnYB1MmH1OhGPqbvr0pbHpq77G8AAk_ts","Suffolk"],
["CambsTimes.d","1HgaWxmf6yz1GvquEfTQZhK7PXCncseE0qqsA_MyynyA","Herts & Cambs"],
["DunmowBroadcast.d","1FJfMN5ziRznrDo6yMeRKC8_NoOYQvvgRPwOVPE9TRJE","Herts & Cambs"],
["ElyStandard.d","1JiZ9-o7QTfhDkXlRkRWVQBlCVNQ5S-rsW5Q3sCn6zqI","Herts & Cambs"],
["HertsAdvertiser.d","1AMM3fJcQR5YqNXheYam7MZ0yAKX6UlbjMTJArWWIJmA","Herts & Cambs"],
["HuntsPost.d","1PL00DU-W7K8kfQL3TVI8DzBJZg2a0QjzY7_gffGOQHA","Herts & Cambs"],
["RoystonCrow.d","1NJSKKxR4Sy-pHdeRdDZQY4FRg_-ruM0qw8mf6N4nfK0","Herts & Cambs"],
["SaffronWaldenReporter.d","1DG3y_90cfPMVdvs1Awwv3NRFX9TC2JJpMJdEXfIcL-8","Herts & Cambs"],
["Comet.d","1B9wFglgR4_AwwcqdCTWz7BF6uVhVmA4CEWfDsth8440","Herts & Cambs"],
["WelwynHatfieldTimes.d","1kU1g4QtPUzyLUD8JAp9lZAWr3-kY2gnc8VfsM82jLmc","Herts & Cambs"],
["WisbechStandard.d","1fmsnlLCZxR3lbYFLs3ABhzk-fcgZlbHQfxPKqs3LlkQ","Herts & Cambs"],
["BarkingDagenhamPost.d","1Qv7brfmCGlAinKlgniRi488BeFvbfEWbtGjDE7RvecU","London"],
["BexleyTimes.d","1v6OM9eNKutvtjcwbZ2glXPrJrkbYgCWwLJhouHOTItQ","London"],
["BromleyTimes.d","1mUCh-nryP4RqDDIGivNPHxSqXidRFgo3-HUcLI646fg","London"],
["EastLondonAdvertiser.d","1b74DjUEeiXWAHY5NNu5jiR0MtpuC70HRh4fEH1X2n20","London"],
["GravesendReporter.d","1SBN8C0moIb_cSRrVWUcB9jKFxyjFxus3uuWz0_rKub0","London"],
["HackneyGazette.d","11AM1_t_74Ya-lpB5blz64LTPXcKR8TSgxpiCInCndwE","London"],
["HampsteadHighgateExpress.d","1Rb9I5G8fJkXVEpT2tRX_tLLho2Xe-HAhsbC_rPu1xnw","London"],
["IlfordRecorder.d","1ZDxit9IAhkUWcUGolcPFthB41eo4rPQ4RQFPKL9xY5o","London"],
["IslingtonGazette.d","1p_0DOmyiA396LpoQ2u4dUVVUiRis1NzAKYX7h_SSs98","London"],
["KentNews.d","185dpQScxZLqMHYTGWw7r0zroVTY8CU55AdqS4b2tTpk","London"],
["KilburnTimes.d","1-Mej3sZeomZkvnaluIwWOAiuSSu8IRwjCZd257NO5zs","London"],
["NewhamRecorder.d","11L68lCWHCOkZkFNnGasT6P8KRVg8zlpx4TJ_9F8nFmA","London"],
["RomfordRecorder.d","13Ijy-8EOSOdLZcCrw0_vhPaso0tnAN51ag54cKZ1BvE","London"],
["CranbrookHerald.d","19afuMmbjw6ajUH7lnbyzrVPaSU49SUUAt_3Uw6mZC9U","South West"],
["Devon24.d","17WqpNo-66eyN2LHm8UhSfyJ-XVf8SaW3vdkUKJaaOC0","South West"],
["ExmouthHerald.d","1uR-C5DDsXRAL4zPd-_71E0qDF-Kh8zSzDP4oKKxpDiM","South West"],
["ExmouthJournal.d","1ztbyvOZQ7T9xKzHQskUzFsD6xyqMLobrbCwa8JRZswk","South West"],
["MidweekHerald.d","1UemEkgwwm6GNFHfGZ2CX11HxAh2fwCDuOq05-LPUCYk","South West"],
["NorthDevonGazette.d","1J_cAiIsf-99CsKU1uLp-CCPqwflG_sGsxJNQB1FnFK0","South West"],
["NorthSomersetTimes.d","1b0fN3INfgdSdnYu1Q9TreNrticmFME_njKGeG2OcBqc","South West"],
["SidmouthHerald.d","1_SzQUSpMXmRJuH7-CL1Q6_0_tr3Mu4eEW6e7nmonMi4","South West"],
["WestonMercury.d","1gMik3D3kKeF4jWk88LDowlSkYQiEszGy6SurminedrM","South West"],
["TheNewEuropean.d","1A45zVMuLID_VESWfM8J697B3f-dzm3L2wxCFsFelJrA","Other"]
])
## nab bits from array to use in template
#foreach( $item as $siteList )
#if( $m.context.site.bean.externalId.externalId == $item.get(0) )
#set( $sheetlink = $item.get(1) )
#set( $group = $item.get(2) )
#end
#end
## setting the group sheet link from group
#if ($group == "Norfolk")
#set($groupsheetlink = "1_SuqIRo1AaDwQhXPaCLYnnWWNEA3Kxdb2YYZkI10RoE")
#elseif ($group == "Suffolk")
#set($groupsheetlink = "1_kDwvcMH8Cii4Wl3O50780A_dCwi7ESyAcZzHFzG7Ew")
#elseif ($group == "Herts & Cambs")
#set($groupsheetlink = "1Ur4J_L5kT2br1A7TkuSBAaNaqPstv0AmTWyFMFai8Rc")
#elseif ($group == "London")
#set($groupsheetlink = "1-tlZ-L5wL2uOkrcSRkZJ54vFb9nSbqurp2IEsOcmKG8")
#end
## output template area below, basic prints for now as I dont have the template ready
<p>
<strong>Sheetlink:</strong> $sheetlink <br />
<strong>Group:</strong> $group <br />
<strong>Group Sheet:</strong> $groupsheetlink <br />
</p>
$m.context.site.bean.externalId.externalId returns the website id, as set within our multisite cms, so that if statement within the foreach bit is nabbing the bits it needs per site.