Tags plugin
Description
The Tags plugin is still very basic. It produces either a list of all tags that are in the Frog database, or it produces the same list with a count of the number of times the tag is used.
License
This plugin is licensed under the GPLv3 License.
Current version
v1.0.0 (download)
- Added displayTagCloud and getTags.
- Improved displayTagList and displayTagListWithCount.
You can also see all downloads for Frog on this site.
You can also see the complete changelist for all versions of this plugin.
How to create a page that displays all links to all pages for a specific tag
- Make sure the Tags plugin is installed and activated.
- Create a page.
- Add this code to it.
<?php
$pages = $this->tags->pagesByTag();
if($pages){
echo "<h3>Pages tagged with '".$this->tags->tag()."'</h3>";
echo '<ul>';
foreach($pages as $slug => $page) {
echo '<li>'.$page->link().'</li>';
}
echo '</ul>';
}
else {
echo 'There is no items with this tag.';
}
?>
- Make sure the page you created is of Page Type "Tags".
- When you named you page "tag", the URL would be ../tag/tagname.html to get an overview of all pages tagged with "tagname".
What you can use in Pages/Snippets/Layouts
getTags('desc', true, false)
Returns an array of strings. Each string is a tag with an optionally shown count.
Parameters:
- The first parameter describes whether or not to sort ASCending or DESCending. When omitted, default is DESCending.
- True or false. When true, a count is added to the string. When used, the first parameter is mandatory.
- True or false. When true, sorts by the count instead of the name. When used, the first two parameters are mandatory.
displayTagList();
This displays a list of all tags that exist in the database.
Output per tag: <li>tagname</li>
displayTagListWithCount('asc');
This displays a list of all tags that exist in the database with the number of times they are used. The list is sorted by count. Default is descending, adding a string parameter with any value other than 'desc' will sort it ascending.
Output per tag: <li>tagname (99)</li>
displayTagCloud('asc')
Displays a tag cloud when combined with the CSS code below. You can sort the cloud's entries in three manners:
- displayTagCloud() - Entries are shown based on DB order.
- displayTagCloud('asc') - Entries are sorted ASCending.
- displayTagCloud('desc') - Entries are sorted DESCending.
Example CSS code:
ul.tagcloud {
list-style-type: none;
padding: 0.3em;
}
ul.tagcloud li {
display: inline;
margin: 0em 0.5em 0em 0em;
}