/
template-country-single.php
48 lines (39 loc) · 1.38 KB
/
template-country-single.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* Template Name: Country | Single
*
* Methods for TimberHelper can be found in the /functions sub-directory
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.1
*/
require_once( get_template_directory() . '/classes/EqarApi.class.php' );
$eqarApi = new EqarApi();
$context = Timber::get_context();
$context['post'] = new TimberPost();
$context['pages'] = array(
'qa_results' => get_field('qa-results_page'),
'agency' => get_field('agency_page'),
'members' => get_field('members_page'),
'cross_border' => get_field('cross-border_page'),
'european_approach' => get_field('european-approach_page'),
'country' => get_field('country_page') ?: $context['post']->link ,
);
// Check if the agency is set.
if ( isset($_GET['id']) && !empty($_GET['id']) ) {
// Get the agency ID from the GET variable.
$countryId = $_GET['id'];
$country = $eqarApi->getCountry( $countryId );
if ( isset($country) && !empty($country) && $country != false ) {
$context['country'] = $country;
} else {
Site::do404();
}
$allCountries = $eqarApi->getCountries();
$context['countriesAll'] = $allCountries;
} else {
Site::do404(400, "Country ID must be provided.");
}
// Render the twig template.
Timber::render('country-single.twig', $context);