klox7 VIP
Total posts: 914
21 May 2015 19:20

Hi,

based on this documentation I want to show in category above records list how much articles are in this category.

I did this and it kind of works. %d is only the number of records listed on page and not from whole category. So if my pagination limit is at 10 it will say "10 records found", if 20 it wil say "20" records found.

How can make it so that pagination will not limit me?

$api = new CobaltApi();
$data = $api->records(null, 'all', null, null, null, null, null, null, null, null, null, $ids);
echo JText::sprintf('Total found %d records', $data['total']);

Last Modified: 28 May 2015


Sergey
Total posts: 13,748
22 May 2015 05:50

That is right. The total of records API is how many articles have been returned.

You want in category or you nees category and it's subscategories?


klox7 VIP
Total posts: 914
22 May 2015 07:34

I need in category but I need number of all articles in category, not just on a page of category.

So If I have total of 40 articles I need number 40, even if category is on 3 pages.


pepperstreet VIP
Total posts: 3,837
23 May 2015 01:26

Hello, isn't there a "Total Num" in Categories module and also in Category Index templates? Maybe you can get some inspiration and code from there...

(Maybe it is a different story doing it with API ? What about the "limit" parameter ? Does it have an impact on the calculation?)


klox7 VIP
Total posts: 914
23 May 2015 10:23

Hi, thanks for suggestion but it somehow outputs NULL when doing var_dump.

But I gues something with $cat->records_num could be done.

pepperstreet What about the "limit" parameter ? Does it have an impact on the calculation?

Yes, with api method limit parameter (pagination) does have an impact on calculation. It only shows number of records on page, not in all category.

@Sergey what is num_all in js_res_categories table and why is it everywhere 0.


Sergey
Total posts: 13,748
27 May 2015 15:53

klox7 @Sergey what is num_all in js_res_categories table and why is it everywhere 0.

I planned to use it to save number of articles in category and its node. But calculation turned out to be very hungry for resources. So I did not do that.

klox7 I need in category but I need number of all articles in category, not just on a page of category.

Then you need to create SQL query to count.

Powered by Cobalt