related.php - filters similar job names

$category $ post_1 merged

  • $category = 'Chemical Engineer'
  • $post_1 = Chemical Engineer, AO, JE, Clerk, MTS
Then
  • Final Result will be Chemical Engineer, AO, JE, Clerk, MTS
  • Why Needed?
  • On Chemical Engineering Jobs Page
  • I want to show the profile Chemical Engineer first then other jobs follows.
<?php
$category = $listing->keyField('cat_1');
?>

<?php if (!$recommendedListings->isEmpty()): ?>

<?php foreach ($recommendedListings as $recommendedListing): ?>
<?php if ($recommendedListing->id != $listing->id): ?>

<li>
<a class="d-block" href="<?= route()->url('frontend.listings.show', ['id' => $recommendedListing->generateSlug()]) ?>">
<?= $recommendedListing->keyField('org_1') ?>
<?= $category . ', ' . implode(', ', array_filter(array_map(function ($p) use ($category) {
$c = strtolower(str_replace(['-', '_'], ' ', trim($p)));
return $c != strtolower($category) ? trim($p) : null;
}, explode(',', $recommendedListing->keyField('post_1'))))) ?>
Recruitment 2026
<!--<?= $recommendedListing->keyField('total_vacancy') . ' ' . $recommendedListing->keyField('post_2') . ' ' . ((int)$recommendedListing->keyField('total_vacancy') === 1 ? 'Vacancy' : 'Vacancies') ?>-->
</a>
</li>
<?php endif; ?>
<?php endforeach; ?>

<?php endif; ?>

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.