Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#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
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
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
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