Previously I asked for help to make this list on the home page, but because I was bored waiting for the end I tried to make it myself, and this is the result.
For a demo, please visit
http://forum.instanesia.id
Insert this code on
/modules/homepage/index.php (+/-)
if ($db->query("SELECT `id` FROM `qa_questions`")->rowCount() > 0) {
$question = $db->query("SELECT * FROM `qa_questions` ORDER BY `created_at` DESC LIMIT 5");
$last_qa = [];
while ($q = $question->fetch()) {
$last_qa[] = [
'id' => $q['id'],
'judul' => $q['title'],
'view' => $q['views'],
];
}
}else {
$last_qa = 'none';
}
$data['last_qa'] = $last_qa ?? [];
echo $view->render('homepage::index', ['data' => $data, 'last_qa' => $last_qa]);
And Insert this code on
/modules/homepage/templates/index.phtml (+/-)
<div class="row">
<?php if ($data['last_job'] !== 'none'): ?>
<div class="col-md-12 col-sm-12 mt-3 tile">
<div class="forums">
<div class="row">
<div class="forums_title">
<svg class="icon">
<use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#book-open"/>
</svg>
<span class="flex-grow-1">Freelancer Jobs</span></div>
<?php foreach($data['last_job'] as $item): ?>
<a href="/job/show/<?= $item['id'] ?>">
<?= $item['judul'] ?>
<span class="myBadge float-right"><?= $item['view'] ?></span>
</a>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
</div>