From f1aca430421038ff27c4c44fbcbc2b5e4fdeec37 Mon Sep 17 00:00:00 2001 From: Matt Way Date: Sun, 4 Aug 2024 22:10:53 +1000 Subject: [PATCH] Filter out candidates that are not for the specified council --- php-template/main.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/php-template/main.php b/php-template/main.php index 4ec267c..8b1df3d 100644 --- a/php-template/main.php +++ b/php-template/main.php @@ -42,6 +42,14 @@ if (($handle = fopen($candidatesFile, "r")) !== FALSE) { exit(1); } +$candidateData = array_filter($candidateData, function ($candidate) use ($councilData) { + return isset($candidate["Council"]) && $candidate["Council"] === $councilData['shortName']; +}); + +if (empty($candidateData)) { + error_log("Failed to load any candidates for " . $councilData['shortName']); +} + $renderer = new SPLPageRenderer(); $pageContent = $renderer->renderCouncilPage($councilData, $candidateData); if ($pageContent === null) {