Add sorting and array_filter for job listing

This commit is contained in:
Maxime St-Pierre 2018-04-26 18:18:14 -04:00 committed by Jeremy Kauffman
parent ed582b7862
commit 9630777ec6
3 changed files with 12 additions and 9 deletions

View file

@ -398,15 +398,18 @@ class ContentActions extends Actions
$jobs = array(); $jobs = array();
foreach(glob(static::VIEW_FOLDER_JOBS . '/*') as $job){ $jobs = array_filter(glob(static::VIEW_FOLDER_JOBS . '/*'), function($job){
list($metadata, $jobHTML) = View::parseMarkdown($job); list($metadata, $jobHTML) = View::parseMarkdown($job);
return $metadata['status'] != 'closed';
});
usort($jobs, function($job1, $job2){
list($metadataA, $jobHTMLA) = View::parseMarkdown($job1);
list($metadataB, $jobHTMLB) = View::parseMarkdown($job2);
return $metadataA['order'] <=> $metadataB['order'];
});
if($metadata['status'] != 'closed')
{
array_push($jobs, $job);
}
}
return ['content/join-us', ['jobs' => $jobs]]; return ['content/join-us', ['jobs' => $jobs]];
} }

View file

@ -1,5 +1,5 @@
<h3> <h3>
<?php echo $metadata['title'] ?><span class="badge <?php echo $metadata['status'] == "active" ? "badge-primary" : "badge-info" ?>"><?php echo $metadata['status'] ?></span></h3> <?php echo $metadata['title'] ?> <span class="badge <?php echo $metadata['status'] == "active" ? "badge-primary" : "badge-info" ?>"><?php echo $metadata['status'] ?></span></h3>
<div class="markdown" <?php echo $jobHTML ?> <div class="markdown" <?php echo $jobHTML ?>
</div> </div>
<?php if(isset($metadata['url'])): ?> <?php if(isset($metadata['url'])): ?>

View file

@ -74,7 +74,7 @@
<div> <div>
<?php foreach($jobs as $job): ?> <?php foreach($jobs as $job): ?>
<?php echo View::render('content/_job', ['job' => $job]) ?> <?php echo View::render('content/_job', ['job' => $job]) ?>
<?php endforeach ?> <?php endforeach ?>
</div> </div>
<h2 id="applying">Applying</h2> <h2 id="applying">Applying</h2>
<h4 id="how-to-apply">How To Apply</h4> <h4 id="how-to-apply">How To Apply</h4>