Skip to content
An ExpressionEngine plugin that displays a list of categories in a tag cloud format, where each category is assigned a CSS class based on its popularity.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
system/expressionengine/third_party/nyan
.gitignore
README.md

README.md

Status: Inactive

Nyan

This project is inactive and no longer being maintained.

Nyan is an ExpressionEninge plug-in that displays a list of categories in a tag cloud format, where each category is assigned a CSS class based on its popularity.

Installation

  • Copy the nyan folder to your /system/expressionengine/third_party/ directory.

Features

  • No forced inline styles: use your own CSS.
  • Define your popularity styles using 1 or 100 classes. You decide.
  • Display the entry count next to each category.
  • Set the minimum number of entries a category needs to appear in the results.
  • Limit your results to a maximum number of categories.
  • Use any combination of categories, irrespective of channel.

New!

  • Filter category results by the entry date, expiration date and status of the related channel entries.

Parameters

Parameter Type Default Description Required
cat_id string Comma or pipe delimited string of category group ids. Yes
class string Class(es) for the outermost list container.
id string ID for the outermost list container.
debug yes|no no Set to "yes" to enable debugging.
limit int Maximum number of categories to show.
min_count int 0 Minimum number of entries a category needs to appear in the results.
order abc|pop pop Set to 'abc' for alphabetical or 'pop' for popularity / ordering by entry count.
parent_only yes|no no Set to "yes" to return only parent categories; no sub-categories will be displayed.
scale string 'not-popular, mildly-popular, popular, very-popular, super-popular' Comma or pipe delimited string of classes ordered from least to most popular.
sort asc|desc desc Set to "asc" or "desc" (optional, default is 'desc'.
status string Comma or pipe delimited string of channel entry statuses. Channel entries without the supplied status(es) are excluded from the category results.
start_date string Channel entries published prior to this date/time will be excluded from the category results.
end_date string Channel entries published after this date/time will be excluded from the category results.
expired yes|no no Set to "yes" to include expired channel entries in the category results.

Start and End Dates

The start_date and end_date parameters are interpreted using PHP's strtotime function and allow for a variety of formats (e.g. "last month", "yesterday", "now", "-1 week", "2013-01-09 00:00", etc). See this page and the examples below for more details.

Single Variables

Variable Description
{cat_id} The ID of the category.
{cat_name} The name of the category.
{cat_url_title} The URL title of the category.
{cat_entry_count} The number of entries the category is used in.
{cat_weight} The CSS class assigned to the category as measured by its popularity.
{parent_id} The parent ID for the category.

Additional Single Variables

Variable Description
{count} The count out of the current category.
{no_results} Conditional (e.g. {if no_results}No Results!{/if}) for displaying a message when no data is returned.
{switch=''} Rotates through any number of pipe delimited values.
{total_results} The total amount of categories returned.

Examples

Basic usage

{exp:nyan cat_id="1"}
<li class="{cat_weight}">{cat_name} ({cat_entry_count})</li>
{/exp:nyan}

Multiple categories

{exp:nyan cat_id="1|2|3"}
<li class="{cat_weight}">{cat_name} ({cat_entry_count})</li>
{/exp:nyan}

Custom classes for category weight

{exp:nyan cat_id="1" scale="not-popular, popular, very-popular"}
<li class="{cat_weight}">{cat_name} ({cat_entry_count})</li>
{/exp:nyan}

Limit categories by popularity

This example will only return categories that are used by 2 or more channel entires.

{exp:nyan cat_id="1" min_count="2"}
<li class="{cat_weight}">{cat_name} ({cat_entry_count})</li>
{/exp:nyan}

Limit the total categories returned

This example will display only 2 categories.

{exp:nyan cat_id="1" limit="2"}
<li class="{cat_weight}">{cat_name} ({cat_entry_count})</li>
{/exp:nyan}

Filter category results by channel entry date and status

This example will exclude channel entries with the following conditions:

  • The entry is dated before last month (e.g. start_date="last_month")
  • The entry is dated after the current date/time (e.g. end_date="now")
  • The entry does not have a status of "open"
  • The entry has an expiration date and expired on or before the current date/time

Unless the expired parameter is set to "y" or "yes", The last condition is always true.

{exp:nyan start_date="last_month" end_date="now" status="open"}
<li>{cat_name} ({cat_entry_count})</li>
{/exp:nyan}

Include expired entries

{exp:nyan expired="y"}
<li>{cat_name} ({cat_entry_count})</li>
{/exp:nyan}

Additional tags example

{exp:nyan cat_id="1" id="my-id" class="my-class"}
<li class="{cat_weight} {switch='odd meow|even meow-meow'}">
	<a href="category/{cat_url_title}">{count} of {total_results}: {cat_name} ({cat_entry_count})</a>
	{if no_results}Sorry, no results.{/if}
</li>
{/exp:nyan}

Example with CSS

{exp:nyan cat_id="1" class="categories"}
<li class="{cat_weight}">
	<span>{cat_entry_count} entries in</span> <a href="category/{cat_url_title}">{cat_name}</a>
	{if no_results}There are no categories to display.{/if}
</li>
{/exp:nyan}

The following CSS will render a traditional tag cloud style list of categories and assumes the "class" parameter is set to "categories":

.categories li { display: inline; }
	
/* Hide only visually, but have it available for screenreaders: h5bp.com/v */
.categories span {
	border: 0; 
	clip: rect(0 0 0 0); 
	height: 1px;
	margin: -1px; 
	overflow: hidden; 
	padding: 0; 
	position: absolute; 
	width: 1px; }

/* Nyan classes */
.categories .not-popular { font-size: 1em; opacity: .2; }
.categories .mildly-popular { font-size: 1.4em; opacity: .4; }
.categories .popular { font-size: 1.8em; opacity: .6; }
.categories .very-popular { font-size: 2.2em; opacity: .8; }
.categories .super-popular { font-size: 2.6em; opacity: .95; }

Change Log

v1.0.2

  • Added the ability to filter category results by the entry date, expiration date and status of the related channel entries.

v1.0.1

  • Initial release
You can’t perform that action at this time.