Download: Category Lister v1.02
Description:
Cat_lister allows for a very flexible way of displaying your categories in the style you want to use. Categories can be displayed alphabetically, ranked, by date, nested, and pseudo nested (see below). Categories can be sorted ascending, descending, hierarchical, or by custom order. Category lists can be limited in length (good for rankings), limited to depth, or without (intelligently evaluated) “empty” categories included.
Also included, and in fact the original reason for the plugin in the first place, are entry and comment statistics. Statistic include entries per category, comments per category, total entries per categories (include subcategories), and total comments per categories (including subcategories).
In addition, several formatting options were not available with the original tag. You can now specify as HTML Ordered or Unordered list, plain list (no formatting added), or with included “Nesting Levels”.
With these options you should be able to create the category list that you want with little or no programming. It is hoped that this plugin will reduce your time and head scratching on working out the custom queries and sorts.
Author:
Jeff Barsky, Sysop of Miasma Of Musings
Intended Platform:
Expression Engine v1.3.1
(Developed and tested on EE 1.3.1, but there is no reason to believe it should not work on other versions of Expression Engine. If you test it on other versions and it works, please let me know. Use our Contact Form.)
Download Links:
Zipped Version: pi.cat_lister.zip (8k)
Text Version: pi.cat_lister.txt (23k)
Word Doc Documentation: pi.cat_lister_doc.zip (32k)
Version/Release Date:
Version 1.02 - October 26, 2005
Version 1.01 - October 13, 2005
Version 1.0 - October 12, 2005
Release History:
Version .9 - October 6, 2005 (Pre-Release)
Version 1.0 - October 12, 2005 (Initial Release)
Version 1.01 - October 13, 2005 (Security Fix)
Version 1.02 - October 26, 2005 (Bug Fix)
Basic usage
for the Cat_lister plugin is rather straightforward. The following example would
create a simple list of categories with the number of entries and comments within
each category:
{exp:cat_lister
weblog=" {master_weblog_name}"}
<a href="http://www.home.com/index.php/weblog/C {cid}/"
> {name}</a>
( {entries}/ {comments})<br
/>
{/exp:cat_lister}
Resulting
in a list this may look something like this:
Entertainment
(45/443)
News (12/203)
Personal
(8/45)
Politics
(19/392)
Simple and
to the point, this example assumes that you do not have any subcategories, but one
simple change could take that into account and show off the power of the “Pseudo-Nested”
ability:
{exp:cat_lister
weblog=" {master_weblog_name}"}
<a href="http://www.home.com/index.php/weblog/C {cid}/"
> {ps_name}</a>
( {entries}/ {comments})<br
/>
{/exp:cat_lister}
Now if you
have subcategories, you may have a list like this:
Entertainment
(45/443)
Entertainment
– Movies (20/443)
Entertainment
– Television (6/443)
Entertainment
– Television – Comedy (2/443)
Entertainment
– Television – Drama (4/443)
Entertainment
– Theater (3/443)
News (12/203)
Personal
(8/45)
Personal
– Dating (3/45)
Personal
– Career (2/45)
Politics
(19/392)
The advantage
of the “Pseudo Nested” list is that you will not have to provide a huge amount of
CSS definitions to have it display well. It is a fast and easy why to display your
hierarchical list and not think about it.
To turn the above tag into an
HTML ordered list you may want to use the following example:
{exp:cat_lister
weblog=" {master_weblog_name}" display_style=”NListO”}
<a href="http://www.home.com/index.php/weblog/C {cid}/"
> {name}</a>
( {entries}/ {comments})<br
/>
{/exp:cat_lister}
And the
resulting list would look like this:
- Entertainment
(45/443)
-
Movies (20/443)
-
Television (6/443)
i.
Comedy (2/443)
ii.
Drama (4/443)
-
Theater (3/443)
- News
(12/203)
- Personal
(8/45)
-
Dating (3/45)
-
Career (2/45)
- Politics
(19/392)
At this
point you will want to add some CSS definitions to allow you to format the list
the way you want it. This is just the simplest of samples.
The following
is an example of the “Nesting Level” type of output. First, a little bit of discussion.
The “Nesting
Level” scheme came about when I was having problems putting a nested list next to
an image and it was rendering differently in different browsers. Therefore, I had
to figure out a way of creating the list without using an HTML nested list. This
led me to styles dependant on padding and thus the “Nested Levels” idea. The advantages
are that you can place them next to just about anything and they should render correctly.
The disadvantage is that you have to define a level for each “Depth” your list goes
deep. If you have control of the category list and the depth it goes, then you can
use this method without any problem. On the other hand if you are not in control
of the category list and the depth of the nested levels exceeds the defined CSS
it will look awful, in which case I recommend you use HTML lists to accomplish the
same thing.
In the next
version of this plugin I will have the plugin write the appropriate CSS to have
this work at any level, but for now, you are going to have to self-limit as appropriate.
As I said, for me this is not problem, but you will have to make the determination
on your own.
(Change
to suit your application of course)
<style>
.cat1
{ font: bold 10px 'Lucida Grande', Verdana, Arial, Sans-Serif;
width: 230px;
padding-left: 0px;
background: #dddddd; }
.cat2
{ font: 10px 'Lucida Grande', Verdana, Arial, Sans-Serif;
text-decoration: none;
width: 215px;
padding-left: 15px;
background: #cccccc; }
.cat3
{ font: 10px 'Lucida Grande', Verdana, Arial, Sans-Serif;
text-decoration: none;
width: 200px;
padding-left: 30px;
background: #bbbbbb; }
</style>
This
will allow for a nested list up to three levels deep. Beyond that, you will have
to add to the style definitions. Here are three samples that I think you will find
useful:
This example
is a simple version of “Nesting Levels” and creates the sample below it. In theory
it should look very similar to the above examples but without the “List” tags in
the underlying code. From a modern coding standpoint this is fairly advance in that
it uses all CSS to create the effect. There are no tables and of course no lists
to get in the way of the display.
{exp:cat_lister
weblog=" {master_weblog_name}"}
<div
class="cat {nest_lvl}">
<a href="http://www.miasmaofmusings.com/index.php/weblog/C {cid}/">
{name}</a>
( {total_e}/ {total_c})</div>
{/exp:cat_lister}
|
Entertainment (45/443)
|
|
Movies (20/201)
|
|
Television (6/52)
|
|
Comedy (2/18)
|
|
Drama (4/28)
|
|
Theater (3/80)
|
|
News (12/203)
|
|
Personal (8/45)
|
|
Dating (3/12)
|
|
Career (2/19)
|
|
Politics (19/392)
|
Want
to add a bullet in front of each, change the “ {name}”
to “•
{name}” and there you
go. Easy, instant bulleted, hierarchical list.
OK, so
you do not like the crowded nature of the list. The numbers are too close to the
categories and you want to see them maybe all the way to the left. Why not try this:
{exp:cat_lister
weblog=" {master_weblog_name}"}
<div
class="cat {nest_lvl}"><div style="float: left;">
<a href="http://www.miasmaofmusings.com/index.php/weblog/C {cid}/">
•
{name}</a></div>
<div
align="right">( {total_e}/ {total_c})</div></div>
{/exp:cat_lister}
|
· Entertainment
|
(45/443)
|
|
· Movies
|
(20/201)
|
|
· Television
|
(6/52)
|
|
· Comedy
|
(2/18)
|
|
· Drama
|
(4/28)
|
|
· Theater
|
(3/80)
|
|
· News
|
(12/203)
|
|
· Personal
|
(8/45)
|
|
· Dating
|
(3/12)
|
|
· Career
|
(2/19)
|
|
· Politics
|
(19/392)
|
When
the above is displayed in a page this will look nice and professional and so simple
to do.
How about
using the nesting level with the “Pseudo Name” convention? You can get an interesting
effect with that. In this case you will not be using the “Nesting Level” as a way
of indenting, but a way of shading to denote the depth of the selection adding a
visual clue as to the location of the category.
The CSS
for this example:
<style>
.cat1
{ font: bold 10px 'Lucida Grande', Verdana, Arial, Sans-Serif;
text-decoration: none;
background: #dddddd; }
.cat2
{ font: 10px 'Lucida Grande', Verdana, Arial, Sans-Serif;
text-decoration: none;
background: #cccccc; }
.cat3
{ font: 10px 'Lucida Grande', Verdana, Arial, Sans-Serif;
text-decoration: none;
background: #bbbbbb; }
</style>
{exp:cat_lister
weblog=" {master_weblog_name}" p_separator=”
· “}
<div
class="cat {nest_lvl}"><div style="float: left;">
<a href="http://www.miasmaofmusings.com/index.php/weblog/C {cid}/">
{ps_name}</a></div>
<div
align="right">( {entries}/ {comments})</div></div>
{/exp:cat_lister}
|
Entertainment
|
(45/443)
|
|
Entertainment · Movies
|
(20/201)
|
|
Entertainment · Television
|
(6/52)
|
|
Entertainment · Television · Comedy
|
(2/18)
|
|
Entertainment · Television · Drama
|
(4/28)
|
|
Entertainment · Theater
|
(3/80)
|
|
News
|
(12/203)
|
|
Personal
|
(8/45)
|
|
Personal · Dating
|
(3/12)
|
|
Personal · Career
|
(2/19)
|
|
Politics
|
(19/392)
|
By combining
the parameter, styles and available information (nesting level) you can create just
about any output you can think of. Already I am thinking about rollover possibilities
and background images and the like making this plugin very versatile indeed.
|