Display tags in Frog CMS
Frog CMS is extremely extendible and you can do just about anything you want with it. After developing the Tagger plugin i was asked on the Frog CMS forum how to make the links at the bottom of each post clickable, so in a few minutes i explored this and came up with a quick trick.
Here is how you can display your tags as link if you are using the Tagger plugin to replicate the look of wordpress. Simply look for the line inside of your article that says:
tags: <?php echo join(', ', $article->tags()); ?>
and change it to the line of code below.
<?php $i = 1; foreach($article->tags() as $tag){ ?>
<a href="<?php echo BASE_URL . 'tags/' . $tag . URL_SUFFIX; ?>"><?php echo $tag; ?></a>
<?php echo $i == count($article->tags()) ? '.' : ', '; $i++ ?>
<?php } ?>
So in line 1 of the code we run a foreach loop to get each tag individually since they are stored in a array.
<?php $i = 1; foreach($article->tags() as $tag){ ?>
We then setup the link so that the tags will go to the Tagger page that is setup by default when you install Tagger so the slug for this page is tags.
<a href="<?php echo BASE_URL . 'tags/' . $tag . URL_SUFFIX; ?>"><?php echo $tag; ?></a>
Following on to line 3 we check against the variable i which was set on line 1 to see if the amount of tags are equal to the variable i and based on this we either show a comma after the tag or a full stop.
<?php echo $i == count($article->tags()) ? '.' : ', '; $i++ ?>
Related posts:





Comments
We currently have 0 comment, come on Say something
Add a comment