Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-08-02 08:41:23

wornout
Member
From: Italy
Registered: 2009-01-20
Posts: 256
Website

Switch form for even or odd articles

Is there a solution or a plug-in to simply switch form rendering between even or odd results?
Something like:

<txp:if_even>
Form with even id or class
</txp:if_else />
Form with odd id or class
</txp:if_even>

Thanks!

Offline

#2 2010-08-02 09:20:24

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Switch form for even or odd articles

Try the zem_nth plugin.

Offline

#3 2010-08-02 15:14:18

wornout
Member
From: Italy
Registered: 2009-01-20
Posts: 256
Website

Re: Switch form for even or odd articles

Thanks ruud!!!
I’ve found also two TxpTips solutions for do that in zem_nth topic

Last edited by wornout (2010-08-02 15:14:31)

Offline

#4 2010-08-02 15:45:25

maniar
Member
From: Hamilton, Ontario
Registered: 2010-01-04
Posts: 66
Website

Re: Switch form for even or odd articles

You can also use JQuery:

For example if all your results are inside <ol id="results"> and each result is contained inside a <li> you can put the following in your <head> ;-)

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" >
	$(document).ready(function() {
		$('#results li:even').addClass('even');
	});
</script>

Then you can style #results li.even {} using CSS

Last edited by maniar (2010-08-02 15:48:07)


اردو میں بھی دستیاب Textpattern آپ کے لیے اب

Offline

#5 2010-08-02 15:51:07

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

Re: Switch form for even or odd articles

Or CSS’ nth pseudos.

li:nth-child(even) {
	background: #000;
}

Which also can be used in conjuction with the JavaScript solutions to give those that don’t have JavaScript support same styles.

Offline

#6 2010-08-02 19:43:38

wornout
Member
From: Italy
Registered: 2009-01-20
Posts: 256
Website

Re: Switch form for even or odd articles

Of course jQuery and CSS are good solutions for styling. I’m searching for a method that let me render different structures of html. So zem_nth is the best start point.

Offline

Board footer

Powered by FluxBB