Tags

Current version

v1.0.0 (download)

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.

How to create a page that displays all links to all pages for a specific tag

      <?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.';
      }
      ?>

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:

  1. The first parameter describes whether or not to sort ASCending or DESCending. When omitted, default is DESCending.
  2. True or false. When true, a count is added to the string. When used, the first parameter is mandatory.
  3. 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:

  1. displayTagCloud() - Entries are shown based on DB order.
  2. displayTagCloud('asc') - Entries are sorted ASCending.
  3. 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;
}

Change notes

v0.0.1 - Initial release

v0.0.3 - Added displayTagCloud and getTags. Improved displayTagList and displayTagListWithCount.