Hello guys, i was wondering if there is a possibility to have a custom template for tags, a sort of tags archive.
I’ll try to explain better:
i have this template in site->templates->products
with a controller in controllers->products.php that fetch data this way:
<?php
return function($site, $pages, $page) {
$products = $page->children()->visible()->flip();
if($tag = param(‘tag’)) {
$products = $products->filterBy(‘tags’, $tag, ‘,’);
}
$tags = $products->pluck(‘tags’, ‘,’, false);
return compact(‘products’, ‘tags’, ‘tag’);
};
?>
In the template for products i return the products like this
<?php foreach($products as $product): ?>
<section class=“products”>
<?php foreach($tags as $tag): ?>
<h1 class=“title”><?php echo html($tag) ?></h1>
<?php endforeach ?>
<article class=“product”>
<h2 class=“title”><a href=“<?php echo $product->url() ?>”><?php echo $product->title()->html() ?></a></h2>
<?php if($image = $product->image()): ?>
<figure>
<?php echo thumb($image, array(‘width’ => 380, ‘height’ => 255, ‘upscale’ => true)); ?>
</figure>
<?php endif ?>
</article>
<?php foreach($tags as $tag): ?>
<a href=“<?php echo url(‘products/tag:’ . $tag)?>”> Show all </a>
<?php endforeach ?>
<?php endforeach ?>
</section>
I’d like to obtain a custom template that show all the products in a certain category when i click the Show all link.
Thanks everybody for the help!