Installation
- Download a copy of nth
- Place /system/plugins/pi.nth.php in your /system/plugins folder
Use
- Wrap your weblog in nth tags like so:
{exp:nth class="last_one" interval="4"}
<ul>
{exp:weblog:entries weblog="some-content"}
<li class="{nth}">{title}</li>
{/exp:weblog:entries}
</ul>
{/exp:nth}
Parameters
- class
- Specify the class name you would like to use on each nth element. In the example above, the class would be "last_one".
- interval
- Specify the interval between inserted class attributes. In the example above, a class of "last_one" will be added to every 4th element.
Being Clever
Using nth in the manner described above will generate an empty class attribute for all of the elements that aren't the nth. It's not a big deal, but it might be too messy for some of the more OCD folks out there. To avoid this, simply pass class= to the class parameter like so:
{exp:nth class='class="last_one"' interval="4"}
<ul>
{exp:weblog:entries weblog="some-content"}
<li {nth}>{title}</li>
{/exp:weblog:entries}
</ul>
{/exp:nth}
Just make sure to be vigilant about your spaces when using nth this way.
