Hi!
I have a list of listed pages and I want to get the number of each page to present next to its title.
for some reason Im having a hard time doing it.
this is my poor try:
page controller
<?php
return function ( $page, $site, $kirby ) {
$random = page('articles')->children()->listed()->shuffle()->first();
$articles = page('articles')->children()->listed();
return [
'articles' => $articles,
'random' => $random,
];
};
page template:
<ul class='articles-list'>
<li>
<a href="<?= $random->url() ?>">
<h2><?= $random->title() ?></h2>
</a>
</li>
<?php foreach ($articles->not($random) as $article): ?>
<li>
<a href="<?= $article->url() ?>">
<p><?= $article->pagination()->currentPage()?></p>
<h2><?= $article->title() ?></h2>
</a>
</li>
<?php endforeach ?>
</ul>
any idea how to make it work?
I will appreciate any help!