Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
archive Expand/Collapse months
Hey yall,
I currently use the following code to create a year/month/article index of all of my writing here
I use the following code:
<code>
<!— show the year —>
<txp:if_different>
<h2 class=“year”><txp:posted format=”%Y” /></h2>
</txp:if_different>
<!— show the month —>
<txp:if_different>
<h3><txp:posted format=”%B” /></h3>
</txp:if_different>
<!— article title and link —>
<a href=”<txp:permlink />”><txp:title /></a>
</code>
Using this code prevents me from placing a div around the months, so that I can collapse or expand them, which is convenient for the user when the list becomes rediculously long.
Does anyone know of an alternative solution using core tags and/or plugins?
Thanks yall,
Matthew
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
#2 2006-07-17 19:20:33
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: archive Expand/Collapse months
Would this work? (I didn’t try it)
<txp:if_first_article>
<div>
</txp:if_first_article>
<!-- show the year -->
<txp:if_different>
</div>
<h2 class="year"><txp:posted format="%Y" /></h2>
<div>
</txp:if_different>
<!-- show the month -->
<txp:if_different>
</div>
<h3><txp:posted format="%B" /></h3>
<div class="collapse">
</txp:if_different>
<!-- article title and link -->
<a href="<txp:permlink />"><txp:title /></a><br />
<txp:if_last_article>
</div>
</txp:if_last_article>
Edit: now I tried, and it’s almost working… It’s outputting the first (latest) month and the latest article, and then it starts again with the latest month and the rest of the articles. Ugh! So close… I’ll do some more thinking.
Edit again: I changed the above code and now it’s working. I don’t know how much of a perfectionist you are, this code creates an empty div at the top of the list…
Edit 3: I give up, still no good :( Gotta learn to think before I speak… I think it can be done but you’ll have to have empty divs around the years as well.
Very. Last. Edit.: If you don’t mind empty divs at the top of the list and after the years, see adapted code. At least it validates.
Last edited by els (2006-07-17 20:21:33)
Offline
#3 2006-07-17 20:26:59
- davidarthurs
- Member
- Registered: 2006-06-06
- Posts: 30
Re: archive Expand/Collapse months
Could you not need use javascript ? –
http://moofx.mad4milk.net/
Offline
#4 2006-07-17 20:31:22
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: archive Expand/Collapse months
He’ll need divs to be able to use the javascript :)
Offline
Re: archive Expand/Collapse months
Els,
:)
You’re great. Thanks for working on that. I was trying to do some similar stuff. I’ll play with that code and see what I feel about it. The empty divs aren’t ideal, but as you say, at least it validates. This would be something to bring up at the feature requests perhaps?
I don’t know enough about the <code><txp:if_different></code> tags, but perhaps they could have a parameter for a wraptag and wraptag class? so that anything that is within those elements which are different would be wrapped and therefore become more versatile?
Thanks again,
:)
Matthew
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
#6 2006-07-17 22:13:52
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: archive Expand/Collapse months
I remember we once tried to do a similar thing with if_different and list tags. I can’t find the thread anymore, but I do remember we didn’t figure that out :) I only found this. According to Sencer it, or something similar to what you want, is “doable”, it would be nice because if_different is basically meant for lists, isn’t it?
Last edited by els (2006-07-17 22:15:13)
Offline
#7 2006-07-17 22:22:11
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: archive Expand/Collapse months
Long lists are evil anyway. Use paging (if_different will continue to work).
Offline
Re: archive Expand/Collapse months
Mary,
Good call, and a decent solution, but wouldn’t be nice if you could have both :)
Do you foresee that as a crazy change, or a relatively simple one, or something in between? By the way you have something in your nostrils.
M
ps. Els, thanks again for the help on this one. I have yet to get the JS working and will need someone who is slightly less than bamboozled to help me on that, but that will have to wait till vacation is over :)
Last edited by ma_smith (2006-07-18 20:57:06)
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
#9 2006-07-19 00:11:29
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: archive Expand/Collapse months
Matthew, this javascript is easy to implement, I’ve been using it for a while: http://www.netlobo.com/div_hiding.html.
Offline
#10 2006-07-19 07:45:22
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: archive Expand/Collapse months
Do you foresee that as a crazy change, or a relatively simple one, or something in between?
For…?
Offline
Re: archive Expand/Collapse months
Sorry Mary, the nostril thing distracted me,
The change to add a wraptag parameter to the if_different tag. (and/or) the php involved to make it work now?
Thanks Mary.
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
Re: archive Expand/Collapse months
ps.
Thanks Els, I’ll check out that Javascript
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline