Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-05-19 18:49:03

MuriloA
New Member
Registered: 2012-05-19
Posts: 3

[Solved] Add special class to certain elements of auto generated list?

Hello, I’ve created a gallery page that fits 4 images per row.

All the images have a margin-right value of X and the fourth image of each row has a class that sets that value to 0.

Like this:

<ul>
<li>image 1</li>
<li>image 2</li>
<li>image 3</li>
<li class="nomargin">image 4</li>
<li>image 5</li>
<li>image 6</li>
<li>image 7</li>
<li class="nomargin">image 8</li>
...
</ul>

Is there any way to do that in a Auto Generated List? Possibly using txp tags.

I know I could use this, but it doesn’t work in IE, so it’s not an option.

Thanks in advance.

Last edited by MuriloA (2012-05-19 19:56:06)

Offline

#2 2012-05-19 19:14:08

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,925
Website GitHub

Re: [Solved] Add special class to certain elements of auto generated list?

Here’s a txptips article with an example of a possible approach using txp:tags and adi_calc or aks_var.

If you’re already using jQuery or similar on your site, you could also simply leave things as they are and load selectivzr in a conditional comment for IE 7 + 8. There’s also this if you want to do nth-of-type with jquery for IE.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2012-05-19 19:14:43

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,547
Website GitHub Twitter

Re: [Solved] Add special class to certain elements of auto generated list?

Hi

I now there is a zem_nth plugin, but dont know if it s still working.

Cheers

Offline

#4 2012-05-19 19:55:00

MuriloA
New Member
Registered: 2012-05-19
Posts: 3

Re: [Solved] Add special class to certain elements of auto generated list?

@Dragondz zem_nth worked like a charm, thank you.

Last edited by MuriloA (2012-05-19 19:55:14)

Offline

#5 2012-05-22 11:44:07

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: [Solved] Add special class to certain elements of auto generated list?

You could also do it with etc_query

<txp:etc_query data="<ul>
<li>image 1</li>
<li>image 2</li>
<li>image 3</li>
<li>image 4</li>
<li>image 5</li>
...
</ul>"
query="ul"
replace="li[position() mod 4 = 0]@@class=nomargin" />

Last edited by etc (2012-05-22 11:59:56)

Offline

#6 2012-05-22 12:47:47

MuriloA
New Member
Registered: 2012-05-19
Posts: 3

Re: [Solved] Add special class to certain elements of auto generated list?

Thanks etc, I’ll check your plugin.

Offline

Board footer

Powered by FluxBB