Hi, I am making index page now.
i want to make like this…
and there is 5 tags as you can see… I need to load all tags.
so first I load every title. and I made controllers like this:
<?php
return function($seallist) {
$seallist = page('works');
// fetch the basic set of pages
$articles = $seallist->children()->listed()->flip();
// fetch all tags
$tags = $articles->pluck('tags', ',', true);
// add the tag filter
if($tag = param('tag')) {
$articles = $articles->filterBy('tags', $tag, ',');
}
// apply pagination
$articles = $articles->paginate(10);
$pagination = $articles->pagination();
return compact('articles', 'tags', 'tag', 'pagination');
};
and this is my template… :
<?php snippet('header') ?>
<main class="wrapper-content">
<?php if ($seallist = page('works')): ?>
<?php foreach ($seallist->children() as $item): ?>
<a href="<?= $item->url() ?>"><?= $item->engtitle() ?></a><br>
<?php endforeach ?><br>
<ul class="tags">
<?php foreach($tags as $tag): ?>
<li>
<a href="<?= url($seallist->url(), ['params' => ['tag' => $tag]]) ?>">
<?= html($tag) ?>
</a>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
</main>
<?php snippet('footer') ?>
but with this code, I can load every title but can not load tags…
could you help me…?
regards,