andiamine VIP
Total posts: 289
06 Apr 2014 12:41

Hi my friend main category don't show records count properly, check plz screenshot.

it's a problem in category view file or cobalt records count mothod ?

cat records count

Regards, ANDI

Last Modified: 17 Apr 2014


Konstantin
Total posts: 1,113
07 Apr 2014 07:01

This is not a bug, because counting proceed only in current category not in subcategories.


andiamine VIP
Total posts: 289
07 Apr 2014 08:51

ah ok , so how can i get full count ?


Sergey
Total posts: 13,730
07 Apr 2014 12:18

There is no count for category nodes.


pepperstreet VIP
Total posts: 3,833
07 Apr 2014 16:44

Aah, the old famous discussion ;-)

Somehow, I agree with andiamine. I always stumble upon this (0). But I am also aware of the different viewpoints and applications. It might be Current Category Items / Total Articles / Total Sub-Categories.

Possible workaround for andiamine: Sum up all Sub-Categories totals... and Replace the number of the parent category total. I remember, I did something similar in ME-Resources for the Section(total#).


andiamine VIP
Total posts: 289
08 Apr 2014 07:42

ok thnaks for u help, i will find a solution for that :)


andiamine VIP
Total posts: 289
09 Apr 2014 06:21

pepperstreet Aah, the old famous discussion ;-)

Somehow, I agree with andiamine. I always stumble upon this (0). But I am also aware of the different viewpoints and applications. It might be Current Category Items / Total Articles / Total Sub-Categories.

Possible workaround for andiamine: Sum up all Sub-Categories totals... and Replace the number of the parent category total. I remember, I did something similar in ME-Resources for the Section(total#).

Yes my friend, i found a solution that count but only for 2 levels i think i will share it here soon, and i will add it on Procategories template.

Regards, ANDI


andiamine VIP
Total posts: 289
17 Apr 2014 17:38

Hi friends sorry for late reply, i was very busy. here simple and easy solution to count number of records in current category and their subcategories :

1) add a new option to xml file in cat_nums field :

<option value="2">Number of records in current category and subcategories</option>

2) add this php function inside category view (php file):

function count_subcat_records($category){
$records_t = 0;
foreach($category->children as $i => $cat ){
$records_t += (int)$cat->records_num;
}
return $records_t;
}

3) Replace this code snippet echo $category->records_num; with:

if($params->get('tmpl_params.cat_nums') === '2')
echo count_subcat_records($category)+$category->records_num;
else echo $category->records_num;

This solution already added in ProCategories template Enjoy ! Regards, ANDI


pepperstreet VIP
Total posts: 3,833
17 Apr 2014 18:15

andiamine This solution already added in ProCategories template

Thanks for posting your solution! Might come in handy.

Product Link bookmarked, too. ;-)


andiamine VIP
Total posts: 289
17 Apr 2014 18:27

You are welcome my friend.

Replay Topic
Uploading
Click here to upload and insert file from you hard drive: (png, gif, jpg, jpeg, zip, txt, rar)
Powered by Cobalt