Textpattern Forum

You are not logged in. Register | Login | Help

#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

#3 2006-11-15 03:56:16

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

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

#4 2006-11-15 04:00:54

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: Total Articles in Section divided by 2

Where do you see txp:count?

On a side note I noticed that getcount (line 326) and safe_count (line 226) perform the same action in txplib_db.php. Is there a reason for both?

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

#6 2006-11-15 04:54:38

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

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

#7 2006-11-15 05:02:41

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: Total Articles in Section divided by 2

so it looks like <txp:count /> actually calls the php function count(), so it doesn’t really do anything. I couldn’t find a place where $pretext['count'] every exists. Maybe it was deprecated.

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

#9 2006-11-15 13:32:10

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: Total Articles in Section divided by 2

Well the thing is that I tried it myself and it worked for me. Do you have debugging turned on?

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

Board footer

Powered by FluxBB