So I’ve created a working tag cloud that displays all restaurant category tags (with one fake tag “All” persistent to the front).
<?php $tags = $page->children()->pluck('tags', ',', true); ?>
<ul class="tags-list">
<a href="<?php echo $page->url() ?>"><li class="label">All</li></a>
<?php foreach($tags as $tag): ?>
<a href="<?php echo $page->url() . '/tag:' . $tag ?>">
<li class="label"><?php echo html($tag) ?></li>
</a>
<?php endforeach ?>
</ul>
It works great. However, I’ve gotten a request to alphabetize the results. I cannot for the life of me figure it out. If I add
->sortBy('tags', 'asc')
before pluck(), then it looks like it alphabetizes each result, then groups them. What we would like is for the entire tag cloud to be alphabetized after gathering the results. Any ideas?
And thank you!