:nthAdd a touch of class

Download

Installation

  1. Download a copy of nth
  2. Place /system/plugins/pi.nth.php in your /system/plugins folder

Use

  1. 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.

twitter logo - click to follow us If you'd like to keep up with :nth updates and general Booyant goodness, follow us on the Twitter.