Here's the code for displaying the last 10 forum topics. For simplicity, you can paste it directly into the template.
If you want to keep the template cleaner, it's better to move the use case call to the controller. However, this code will work as is if you paste it into the template.
<?php
// Get forum topics
$topics = di(\Johncms\Modules\Forum\Application\UseCases\ViewLatestTopicsUseCase::class)->execute();
?>
<?php if (! empty($topics->topics)): ?>
<div class="mb-n3">
<h2 class="h1 fw-bold mt-4 mb-2"><?= d__('system', 'Forum') ?></h2>
<div class="row row-cols-1">
<?php foreach ($topics->topics as $topic): ?>
<div class="col mb-3">
<a class="h6 fw-bold" href="<?= $this->e($topic['url']) ?>"><?= $this->e($topic['name']) ?></a>
<div class="text-muted small pt-1">
<?= $topic['show_last_post_date'] ?>,
<?= $this->e($topic['show_last_author']) ?>
</div>
</div>
<?php endforeach; ?>
</div>
<a href="/forum/" class="btn btn-sm btn-outline-secondary mb-4"><?= d__('system', 'Forum') ?> →</a>
</div>
<?php endif; ?>