How can I display all tags? #444
-
Hello. How I can show all tags from blog posts on my homepage? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Simply enter |
Beta Was this translation helpful? Give feedback.
-
How I can show it with html/php in my layout/home.html? |
Beta Was this translation helpful? Give feedback.
-
With the API you have access to all pages. It's a little bit more work to show tags, since each page can have multiple tags, which means you probably want to split page meta data into individual tags. I checked the API documentation, looks like there's no example you can simply copy/paste. As a starting point, see function |
Beta Was this translation helpful? Give feedback.
-
With the latest API you can group/divide a page collection into multiple smaller collections. Example 1 - Layout file to show tags with ascending name, A-Z: <?php $this->yellow->layout("header") ?>
<div class="content">
<div class="main" role="main">
<h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1>
<?php echo $this->yellow->page->getContentHtml() ?>
<?php $pages = $this->yellow->content->index()->filter("layout", "blog")->sort("published", false) ?>
<?php $this->yellow->page->setLastModified($pages->getModified()) ?>
<ul>
<?php foreach ($pages->group("tag") as $tag=>$collection): ?>
<li><?php echo htmlspecialchars($tag)." (".count($collection).")" ?></li>
<?php endforeach ?>
</ul>
</div>
</div>
<?php $this->yellow->layout("footer") ?> Example 2 - Layout file to show tags with descending count, highest first: <?php $this->yellow->layout("header") ?>
<div class="content">
<div class="main" role="main">
<h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1>
<?php echo $this->yellow->page->getContentHtml() ?>
<?php $pages = $this->yellow->content->index()->filter("layout", "blog")->sort("published", false) ?>
<?php $this->yellow->page->setLastModified($pages->getModified()) ?>
<ul>
<?php foreach ($pages->group("tag", false, "count") as $tag=>$collection): ?>
<li><?php echo htmlspecialchars($tag)." (".count($collection).")" ?></li>
<?php endforeach ?>
</ul>
</div>
</div>
<?php $this->yellow->layout("footer") ?> The method |
Beta Was this translation helpful? Give feedback.
With the latest API you can group/divide a page collection into multiple smaller collections.
Example 1 - Layout file to show tags with ascending name, A-Z: