From: Steve Sutton Date: Tue, 19 Jan 2016 16:37:18 +0000 (-0500) Subject: Updates for front end output of search form and listings X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=25bf3928500aaaa99ca0891d5d220c695e9b67fb;p=WP-Plugins%2Fglm-employment.git Updates for front end output of search form and listings If no jobs currently avaible then display non available text. If no jobs then don't show search. --- diff --git a/controllers/front.php b/controllers/front.php index 3221ed7..bd59e3e 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -90,7 +90,10 @@ class glm_employment_front } else if ($job_id) { $this->show_job($job_id); } else { - $this->search_form(); + $number_of_jobs = $this->get_number_of_jobs(); + if ($number_of_jobs) { + $this->search_form(); + } $this->list_jobs(); } $output = ob_get_contents(); @@ -431,6 +434,29 @@ class glm_employment_front return; } + public function get_number_of_jobs() + { + global $wpdb, $wp; + $midnight = strtotime(date('Y-m-d',time()).' 00:00:00'); + $args = array( + 'post_type' => GLM_EMP_POST_TYPE, + 'meta_query' => array( + array( + 'key' => 'glm_jobs_enddate', + 'value' => $midnight, + 'compare' => '>=' + ), + array( + 'key' => 'glm_jobs_startdate', + 'value' => $midnight, + 'compare' => '<=' + ) + ) + ); + $jobs = get_posts($args); + return count($jobs); + } + /** * List the jobs that are currently set to display * based on start and end dates diff --git a/views/front/jobList.php b/views/front/jobList.php index 1cd1cc4..de4eec3 100644 --- a/views/front/jobList.php +++ b/views/front/jobList.php @@ -7,6 +7,9 @@
Status: glm_jobs_status;?>
Full Job Description
- + + +

There are currently no positions available.

+