Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-11-15 03:16:02
- Ace of Dubs
- Member
- Registered: 2006-04-17
- Posts: 446
Total Articles in Section divided by 2
This one is kind of tricky.
I am trying to build a 2-column list that will show all the articles in a given section.
I want both columns to be roughly the same height.
<txp:article_custom section="given" limit="TOTAL_ARTICLES_IN_SECTION(divided by)2" />
<txp:article_custom section="given" offset="TOTAL_ARTICLES_IN_SECTION(divided by)2" />
Is it possible? I’m praying for a PHP miracle
Last edited by Ace of Dubs (2006-11-15 03:17:32)
Offline
#2 2006-11-15 03:29:40
- Ace of Dubs
- Member
- Registered: 2006-04-17
- Posts: 446
Re: Total Articles in Section divided by 2
In related news..
What on earth is TXP:count?
Quite a few people have identified it as a global variable, but nobody knows what it does…
Offline
Re: Total Articles in Section divided by 2
So you can try this
<txp:asy_wondertag><txp:article_custom section="given" limit="<txp:php>echo round(getCount('textpattern', 'status>4 and section="given"')/2);</txp:php>" /></txp:asy_wondertag>
You will need asy_wondertag. The @getCount($table, $criteria)@ function will return the number of articles that match the criteria you give it against the table you give it.
Offline
Offline
#5 2006-11-15 04:13:42
- Ace of Dubs
- Member
- Registered: 2006-04-17
- Posts: 446
Re: Total Articles in Section divided by 2
Thanks a bunch variaas,
I tried your code but article custom is returning articles from all sections for some weird reason..
As for txp:count, I got that from here
Offline
Re: Total Articles in Section divided by 2
Interesting, so if it’s actually displaying the article, then something is happening with the article_custom function. If you changed tag to just the simple <txp:article_custom section="given" limit="20" />
does it show articles from only the “given” section?
Offline
Offline
#8 2006-11-15 13:16:54
- Ace of Dubs
- Member
- Registered: 2006-04-17
- Posts: 446
Re: Total Articles in Section divided by 2
Yup..just tried a basic article_custom like you posted and it works as expected. My problem might be due to limitation of the wondertag plugin. Sencer mentioned that it wasn’t guaranteed to work in all scenarios. I’ll post a crosslink in his thread and see what he thinks.
Thanks again for that code… I would not have known where to start!
Offline
Offline
#10 2006-11-15 14:22:05
- Ace of Dubs
- Member
- Registered: 2006-04-17
- Posts: 446
Re: Total Articles in Section divided by 2
It turns out my database needed some table repair. It works beautifully now
You my friend, are a genius!!!
:D
Offline
Re: Total Articles in Section divided by 2
Beautiful problem. Beautiful solution Thanks! -> del.icio.us
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
#12 2006-12-07 11:43:51
- M_i
- Member
- Registered: 2006-03-05
- Posts: 122
Re: Total Articles in Section divided by 2
This works great, thanks!
I just had to change
getCount('textpattern', 'status>4 and section="given"')/2)
to
getCount('textpattern', 'status=4 and section="given"')/2)
because with the > instead of =, I only got 1 article in the first column, and the rest in the second (I have one sticky in that section)
Offline