Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2011-09-22 14:33:17
- ploinkr
- Member
- From: Montreal
- Registered: 2007-12-06
- Posts: 83
tricky puzzle (to me, at least)
Hi everyone, I’ve been trying to create article lists based on a specific custom field (“Year”), with some of those articles being labeled as “related” and needing to appear in a separate list within the same “block.”
I’ve attached a quick diagram of what I mean, hoping it’ll make sense to some of you(?)
My main question here is I’m not sure where the <article>
tag should be (logically(?), the whole “block” would be the article form
but I just get lost at the “related” material part.)
If anyone can help that’d be tremendously appreciated.
Thanks.
Last edited by ploinkr (2011-09-22 14:35:37)
Offline
Re: tricky puzzle (to me, at least)
Thinking out loud, could you do something like this?
<ul>
<txp:article_custom year="2010" limit="999" sort="related asc">
<txp:if_different>
</ul>
<!-- <txp:custom_field name="related" /> -->
<ul>
</txp:if_different>
<li><txp:permlink /></li>
</txp:article_custom>
</ul>
I’m not sure if that gets you what you want and you may need to find a solution for the extra empty ul at the top (there was one recently but I can’t find it right now). That should give you a set of all articles in 2010 grouped according to related field.
TXP Builders – finely-crafted code, design and txp
Offline
Re: tricky puzzle (to me, at least)
Solution for the extra empty ul: add wraptag="ul"
to article_custom
?
…Prrrrrrrr…
Offline
#4 2011-09-22 19:22:39
- ploinkr
- Member
- From: Montreal
- Registered: 2007-12-06
- Posts: 83
Re: tricky puzzle (to me, at least)
jakob, Arjan, thanks for your replies; I’ll see what I can come up with using your suggestions.
Bye for now :)
Offline
Re: tricky puzzle (to me, at least)
Solution for the extra empty ul: add wraptag=“ul” to article_custom?
No that doesn’t help here. The case is that the first article will (may) trigger txp:if_different
if the first article has a related tag causing it to add an </ul>. You’ll therefore probably get an empty <ul></ul>
right at the top, which isn’t a disaster but not tidy. Using txp:if_first_article inside txp:if_different doesn’t help here either because if_different sees that as different content. You need to do some trickery along the lines of this post.
TXP Builders – finely-crafted code, design and txp
Offline
#6 2011-09-22 22:19:18
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: tricky puzzle (to me, at least)
jakob wrote:
You need to do some trickery along the lines of this post.
Here is an adaptation of that example using list tags (I made it for something else so you’ll need to change it a bit to fit your needs):
<txp:article_custom section="name-of-your-section" sort="custom_6 asc,title asc" wraptag="ul" break="" class="submenu">
<txp:if_different>
<!-- <txp:custom_field name="Label" /> -->
<txp:variable name="label_different" value="yes" />
</txp:if_different>
<txp:if_variable name="label_different" value="yes">
<txp:if_first_article><txp:else /></ul></li></txp:if_first_article>
<li><txp:custom_field name="Label" /><ul>
</txp:if_variable>
<li><txp:permlink><txp:title /></txp:permlink></li>
<txp:if_last_article></ul></li></txp:if_last_article>
</txp:article_custom>
Offline
#7 2011-09-23 00:27:47
- ploinkr
- Member
- From: Montreal
- Registered: 2007-12-06
- Posts: 83
Re: tricky puzzle (to me, at least)
Thanks a lot everyone :) I suspected some variable
magic would be needed.
Will try some of that – thanks again!
Offline
Pages: 1