Recent Topics

Total number of posts in Phoenix

Started by on Dec 07, 2005 – Contents updated: Dec 07, 2005

Dec 07, 2005 00:01    

I am working on a little hack to show a random post from Blog 3 (for quotations and stuff). (something I have seen requested, but noone has offered an answer to) As I work on this, I want to be able to find out how many total posts are in the blog in order to just get one (a random number).

I see there is a function $List->get_total_num_posts

But as I have been looking at it, it seems to return the total number of posts returned in the ItemList call. I don't want to get the full array of posts just to get the count of total rows. (thinking of my poor mysql server)

Is that what I want to call? or is there another way of getting what I want.

I have Phoenix 1.6 (the downloadable version not in CVS)

Dec 07, 2005 20:47

I've been experimenting and digging around since my post.

I have discovered that even if I say to get one post, $ItemList->get_total_num_posts() will return the total number of posts that match the search criteria. So that is good.

Now, I'm trying to figure out how to get the 12th/8th/nth/randomth post within that number. Right now I cannot see how $ItemList->get_item() can get anything other than the first in the stack of posts that ItemList() returns. Currently I am looping through the stack until I hit the nth post and using that one. Since my test pool is only 18 that isn't so bad, but more than that and it will be a problem.

Am I just missing something as I look at the ItemList.class functions? or is this something that the current state of code doesn't address.

Feb 05, 2006 03:23

As far as I know the ItemList does not support this, but the ItemList2, which will replace it, does. There you'll have get_by_idx() (from the DataObject2 class, where ItemList2 is derived from).


Form is loading...

Build your own site! – This forum is powered by b2evolution CMS, a complete engine for your website.