Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-07-04 10:59:38
- snyvo
- Member
- Registered: 2006-08-10
- Posts: 11
How to write a form that increments id of a list tag
Hope I can explain clearly what I am trying to figure out:
Please take a look at my Textpattern driven site (in progress)
http://www.snyvo.com/site/
There’s a list of articles, each block is an article. 12 articles per page.
The form for each article looks like this:
<li class="frontitem">
<txp:permlink>
<h2><txp:title /></h2>
<txp:excerpt />
</txp:permlink>
</li>
In my default page, this code generates the list of 12 blocks:
<ul id="frontitems">
<txp:article limit=12 form="static_article" listform="static_list" />
</ul>
Now, I am looking for a way to generate different li id’s for each block. The first one should have an id of “work1”, the second one “work2”, third one “work3” and so on to “work12”.
If I can get this to work, I can use jQuery to fade in block by block with this piece of Javascript:
$(‘#work1’).animate({opacity: 1.0}, 1).fadeIn(“fast”);
$(‘#work2’).animate({opacity: 1.0}, 100).fadeIn(“fast”);
$(‘#work3’).animate({opacity: 1.0}, 200).fadeIn(“fast”);
…
Can anyone tell me how I can write a form that does this with the li id’s? I need a way to automatically increment the name of my list tag. I am not sure whether this is possible with Textpattern tags. Any help is greatly appreciated!!
Offline
Re: How to write a form that increments id of a list tag
Can you use rvm_counter in any capacity to help in your quest?
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#3 2008-07-04 11:18:22
- snyvo
- Member
- Registered: 2006-08-10
- Posts: 11
Re: How to write a form that increments id of a list tag
I am not sure, do you have any idea how to integrate this counter’s result into the tag id?
Offline
#4 2008-07-04 11:20:40
- snyvo
- Member
- Registered: 2006-08-10
- Posts: 11
Re: How to write a form that increments id of a list tag
if I could get the id problem fixed, the result of the jQuery fade-in script would look like this
http://www.snyvo.com/site/front.html
Last edited by snyvo (2008-07-04 11:20:51)
Offline
Re: How to write a form that increments id of a list tag
snyvo wrote:
I am not sure, do you have any idea how to integrate this counter’s result into the tag id?
<li class="frontitem" id="work<txp:rvm_counter />">
<txp:permlink>
<h2><txp:title /></h2>
<txp:excerpt />
</txp:permlink>
</li>
Offline
Re: How to write a form that increments id of a list tag
EDIT: juanjonavarro beat me to it :-)
I was going to post an identical thing but perhaps with offset="1"
added to rvm_counter if you wanted the counter to start at 1 instead of 0? Doesn’t make much difference really, whichever you choose.
Last edited by Bloke (2008-07-04 11:31:52)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#7 2008-07-04 11:55:56
- snyvo
- Member
- Registered: 2006-08-10
- Posts: 11
Re: How to write a form that increments id of a list tag
wow I had no idea I could nest Textpattern tags just like that (yup, I’m not exactly an expert!) – THANKS!
there’s just one problem: what the rvm_counter plugin counts now, is the number of the articles.
It should however count to twelve, and restart at zero for each new page.
I implemented your form code, so you can have a look at http://www.snyvo.com/site/ again and see the result…
Thanks a lot for your help guys, I owe you one
Offline
Re: How to write a form that increments id of a list tag
Well, this is not exactly tag nesting. You are nesting HTML tags with TxP tags (html tags are really plain text for TxP). To nest txp tags, you need to wait for the next release (4.0.7)
I don’t know exactly what your problem is. The plugin should start a new count on every request. But in your source, your count start at 3 on every request. I don’t know why.
Last edited by juanjonavarro (2008-07-04 12:07:15)
Offline
Re: How to write a form that increments id of a list tag
Untested but perhaps:
<rvm_counter reset="0" />
<ul id="frontitems">
<txp:article limit=12 form="static_article" listform="static_list" />
</ul>
So at the start of each call in an article list it will reset the value back to 0? (or 1 if you choose)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#10 2008-07-04 13:06:10
- snyvo
- Member
- Registered: 2006-08-10
- Posts: 11
Re: How to write a form that increments id of a list tag
I tested the reset option like that, but it doesn’t seem to have any effect.
I think the count does start at 0, but the first page doesn’t list all the articles, it lists the 12 newest articles, there’s 3 more on the previous page. So maybe the li tag was already called three times even though those articles don’t actually show up?
Offline
#11 2008-07-04 13:13:12
- snyvo
- Member
- Registered: 2006-08-10
- Posts: 11
Re: How to write a form that increments id of a list tag
oh wait, it does work properly when I do this:
<txp:rvm_counter reset="0" offset="0" />
<ul id="frontitems">
<txp:article limit=12 form="static_article" listform="static_list" />
</ul>
Grrrrreat! Thanks a lot guys – really, I owe you one!
Last edited by snyvo (2008-07-04 13:17:51)
Offline
Re: How to write a form that increments id of a list tag
No probs. I can’t get my head round that reset
option. The docs just say that offset
is easier to use… *shrug*
Glad you’re up and running now though. Cool.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline