diff --git a/make-council-pages.sh b/make-council-pages.sh
index bed59c6..c821993 100755
--- a/make-council-pages.sh
+++ b/make-council-pages.sh
@@ -38,7 +38,13 @@ function create_or_update_page() {
candidates_file="$DATA_PATH"/$slug/candidates-generic.csv
fi
- content=$(echo "$council_block" | jq -c | php php-template/main.php --council-file "php://stdin" --candidates-file "$candidates_file" --media-file "$DATA_PATH"/$slug/media.json )
+ if test -f "$DATA_PATH"/$slug/candidates-elected.csv; then
+ candidates_elected_file="$DATA_PATH"/$slug/candidates-elected.csv
+ echo "Found candidates-elected.csv"
+ fi
+
+
+ content=$(echo "$council_block" | jq -c | php php-template/main.php --council-file "php://stdin" --candidates-file "$candidates_file" --media-file "$DATA_PATH"/$slug/media.json --candidates-elected-file "$candidates_elected_file" )
if [ $? -eq 0 ]; then
diff --git a/php-template/example-candidates-elected.csv b/php-template/example-candidates-elected.csv
new file mode 100644
index 0000000..5718efe
--- /dev/null
+++ b/php-template/example-candidates-elected.csv
@@ -0,0 +1,2 @@
+Ward,Candidate Name,Elected
+Harvester,Joe Blogs,y
\ No newline at end of file
diff --git a/php-template/main.php b/php-template/main.php
index 3a575a3..6dd43bd 100644
--- a/php-template/main.php
+++ b/php-template/main.php
@@ -1,7 +1,7 @@
$value) {
+ $electedCandidate[$value] = $data[$key];
+ }
+ foreach ($candidateData as &$candidate) {
+ if ($candidate["Candidate Name"] == $electedCandidate["Candidate Name"]) {
+ if ($electedCandidate["Elected"] == "y") {
+ $candidate["Elected"] = True;
+ }
+ break;
+ }
+ }
+ }
+ fclose($handle);
+ } else {
+ error_log('Error opening candidates elected file');
+ exit(1);
+ }
+ } else {
+ error_log("The specified candidates elected file does not exist, will not show any elected candidates for " . $councilData["shortName"] . ".");
+ }
+}
+
$renderer = new SPLPageRenderer();
$pageContent = $renderer->renderCouncilPage($councilData, $candidateData, $mediaData);
if ($pageContent === null) {
diff --git a/php-template/template.php b/php-template/template.php
index 2713ca7..3d794dc 100644
--- a/php-template/template.php
+++ b/php-template/template.php
@@ -151,6 +151,12 @@ if (isset($config["survey"])) {
-
+ ">
+
+ ELECTED
+
+