Splitting up categories

The purpose of this plugin is to split up the output of the {exp:weblog:categories style="linear"}-tag.

This can either be done by manually specifing an offset and a limit or by specifing a number of “columns” resulting in several blocks of categories surrounded by <div>-tags.

It has its origin in this forum thread.

General Usage:

Wrap the {exp:cat_offset}-tags around the {exp:weblog:categories}-tags.

There are two modes of operation.

In ’automatic mode‘ you specifiy a number of columns. The number of categories per columns is determined automatically and blocks surrounded by <div></div> are created. You may specify a classname to be used in the <div>.

Example:

<div class="myclass">
category 1
category 2
category 3
</div>
<
div class="myclass">
category 4
category 5
category 6
</div>
<
div class="myclass">
category 7
category 8
category 9
</div>

In ’manual mode‘ you set an offset and a limit. The output of the categories then starts at the offset and stops when the limit is reached.



AUTOMATIC MODE:

Tag:

{exp:cat_offset:auto}{/exp:cat_offset:auto}

There are three parameters:

columns="X"

Mandatory. Sets the number of columns you want.

class="X"

Optional. Sets the CSS class name for the <div> surrounding a block of categories.

delimiter="X"

Mandatory. This must be a unique string in your {exp:weblog:categories}-output that separates any two categories. Usually the last characters in the line between your {exp:weblog:categories}-tags.

{exp:weblog:categories weblog="default" style="linear"}
<li><a href="{path=site/index}">{category_name}</a></li>
{/exp:weblog:categories}

In the example above the delimiter would be: </li>

{exp:weblog:categories weblog="default" style="linear"}
<a href="{path=site/index}">{category_name}</a><br />
{/exp:weblog:categories}

In the example above the delimiter would be: <br />

I hope you get the point wink

Example:

This creates three blocks of categories surrounded by <div class="catcol"></div>

{exp:cat_offset:auto delimiter="<br />" columns="3" class="catcol"}
{exp
:weblog:categories weblog="default" style="linear"}
<a href="#">{category_name}</a><br />
{/exp:weblog:categories}
{
/exp:cat_offset:auto}



MANUAL MODE:

Tag:

{exp:cat_offset}{/exp:cat_offset}

There are three mandatory parameters:

offset="X"

Sets the number of categories to be skipped before output starts.

limit="X"

Sets the number of categories to be shown before output stops.

delimiter="X"

This must be a unique string in your {exp:weblog:categories}-output that separates any two categories. Usually the last characters in the line between your {exp:weblog:categories}-tags.

{exp:weblog:categories weblog="default" style="linear"}
<li><a href="{path=site/index}">{category_name}</a></li>
{/exp:weblog:categories}

In the example above the delimiter would be: </li>

{exp:weblog:categories weblog="default" style="linear"}
<a href="{path=site/index}">{category_name}</a><br />
{/exp:weblog:categories}

In the example above the delimiter would be: <br />

I hope you get the point wink

Example:
This would skip the first 10 categories and then output (up to) 5 categories.

<ul>
{exp:cat_offset delimiter="</li>" offset="10" limit="5"}
{exp
:weblog:categories weblog="default" style="linear"}
<li><a href="{path=site/index}">{category_name}</a></li>
{/exp:weblog:categories}
{
/exp:cat_offset}
</ul>

Download: pi.cat_offset.zip
2.25 KB

If you found something useful here and want to show your appreciation feel free to

or


Comments:

1 of 1 pages

Actually yes. Even out of the box.

Something like

{exp:cat_offset:auto delimiter="<!-- snip //-->" class="dud" columns="3"}
{exp
:weblog:entries weblog="default_site"}
<h3>{title}</h3>
{body}
<!-- snip //-->
{/exp:weblog:entries}
{
/exp:cat_offset:auto}

should work without problems.

Posted by  on  02/05  at  01:49 PM

Any way of doing this for standard entries too?

Posted by Steven Hambleton  on  02/05  at  04:58 AM

1 of 1 pages