Skip to content

Instantly share code, notes, and snippets.

@shoesforindustry
Last active February 4, 2016 12:26
Show Gist options
  • Save shoesforindustry/5982545 to your computer and use it in GitHub Desktop.
Save shoesforindustry/5982545 to your computer and use it in GitHub Desktop.
#Kirby CMS Produce a comma separated list of tags or categories for a tag/category link list. `$page->tags()` in this case is my array. `tagURL` is of course either category or tags maybe, depending what you are doing in the URL e.g. `http://website.dev/tagURL:tag`
<!-- Code to create a comma seperated linked tags list -->
<ul>
<?php foreach(str::split($page->tags(),',') as $tag): ?>
<li>
<a href="<?php echo url('tagURL/tag:' . urlencode($tag))?>">
<?php echo $tag ?>
</a>
</li>
<?php endforeach ?>
</ul>
<!-- Output from comma seperated linked tags list code -->
<ul>
<li>
<a href="http://website.dev/tagURL:tag">
tag1
</a>
</li>
<li>
<a href="http://website.dev/tagURL:tag">
tag2
</a>
</li>
</ul>
@iskrisis
Copy link

iskrisis commented Feb 4, 2016

I just noticed this GIST. There is kirby function for that, its not much smaller but looks better.

<?php foreach($page->tags()->split(',') as $tag): ?>

Will work the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment