Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-01-07 13:14:43

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

How do I count articles in a list and act on even numbers?

Hi there,

In my article lists (each section’s landing page) I want to apply a certain css attribute only to every 2nd, 4th, 6th etc (basically the even numbers) article in that list, I’m fairly sure this could be achieved using <txp:variable> and <txp:if_variable>, or maybe the aks_var plugin but am not clever enough to work it out.

Could someone please suggest a method to me?

Many thanks,
Phil

Offline

#2 2010-01-07 13:49:24

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: How do I count articles in a list and act on even numbers?

zem_nth

<txp:zem_nth step="2" of="2">
	class="even"
</txp:zem_nth>

Offline

#3 2010-01-07 14:10:50

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: How do I count articles in a list and act on even numbers?

Thanks Jukka, that worked like a charm!

Offline

#4 2010-01-07 14:42:40

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: How do I count articles in a list and act on even numbers?

Here is another method and a variation of the same.

Offline

Board footer

Powered by FluxBB