From 82f65a2050097bf3640a5f03c9e83cc32cbeceba Mon Sep 17 00:00:00 2001 From: Kim Taylor Date: Sat, 21 Sep 2024 16:53:24 +1000 Subject: [PATCH] Generate pledge council index. --- pledge-update/page_renderer.php | 2 +- pledge-update/pledge-page.php | 11 ++++++++- pledge-update/template.php | 41 ++++++++++++--------------------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/pledge-update/page_renderer.php b/pledge-update/page_renderer.php index 773a33a..f7ce2dc 100644 --- a/pledge-update/page_renderer.php +++ b/pledge-update/page_renderer.php @@ -1,7 +1,7 @@ renderPledgePage($councilData, $candidateData, $mediaData); +$councils = []; +foreach ($pledgeCandidates as $key => $candidate) { + $councils[] = $candidate['Council']; +} +$councils = array_unique($councils); +asort($councils); + +//print_r($councils); + +$pageContent = $renderer->renderPledgePage($councils, $pledgeCandidates); if ($pageContent === null) { exit(2); diff --git a/pledge-update/template.php b/pledge-update/template.php index a0cea5c..fe326a3 100644 --- a/pledge-update/template.php +++ b/pledge-update/template.php @@ -5,9 +5,6 @@ function sluggify($input) { } $surveyLink = "Streets People Love Pledge and Survey"; -if (isset($config["survey"])) { - $surveyLink = $config["survey"]; -} ?> @@ -27,12 +24,10 @@ if (isset($config["survey"])) { 1) { - $wardsDescription = $config['councilName'] . " is divided into " . $wardCount . " wards:"; - } else { - $wardsDescription = $config['councilName'] . " is unsubdivided and does not contain any wards."; + if ($councilCount > 1) { + $wardsDescription = "Candidates from " . $councilCount . " wards have taken the pledge:"; } ?> @@ -41,39 +36,33 @@ if (isset($config["survey"])) {

- - -
" target="_blank" rel="noreferrer noopener">" alt="" class="wp-image-" style="width:550px"/>
- - - - 1): ?> + 1): ?> 8) { - $wardListChunkSize = ceil($wardCount / 2); + if ($councilCount > 8) { + $councilListChunkSize = ceil($councilCount / 2); } else { - $wardListChunkSize = $wardCount; + $councilListChunkSize = $councilCount; } - $wardChunks = array_chunk($config['wardNames'], $wardListChunkSize); + $councilChunks = array_chunk($councils, $councilListChunkSize); ?> - -
+ +
- +
    - + -
  • +
  • @@ -87,7 +76,7 @@ if (isset($config["survey"])) {
- +

@@ -195,4 +184,4 @@ if (isset($config["survey"])) {

- \ No newline at end of file +