Sackgesicht VIP
Total posts: 1,636
01 Jun 2017 04:50

1) If you set the category parameter "Allow submit to this category" to "No", it will not compute/display the number of records for this category anymore.

2) Subcategories do not show number of records at all

What would be a better/alternative implementation for the category feature in Cobalt? A new multi-Level-Select field, using the existing multi-level-select field or even another field?

Last Modified: 19 Jun 2017


Sergey
Total posts: 13,748
02 Jun 2017 12:27

Sackgesicht What would be a better/alternative implementation for the category feature in Cobalt?

This question was around for some time.

I know a guy who desided to go with MLS field. And he was happy with that. But later he descovered that real categories netter for SEO.

So if you consider SEO, them perhaps real categories are better because they create uniquie URLs for each actegory. But if SEO is not of any concern, then field would be a propper option too.

It really depends also, how your users are going to interupt with categories and you copability of editing templates. I know that you one of the most capable, but I am saying that in case someone else have the same question.

So for intranet, with your abilities, fields woulf be good option.

But in any sace there is no calculation of records for field value is there?


Sackgesicht VIP
Total posts: 1,636
05 Jun 2017 03:45

After looking into categories, i noticed that they use the same nested set approach as the Multi-Level-Select field. Therefore there is no advantage to use the field. The category approach has even an advantage due to the #__js_res_record_category "fast" counting ...

Unfortunately, the implementation for categories and the multilevelfield is both suboptimal. It should allow for individual trees and not only 1 tree. In categories it should have 1 tree per section and in the multilevel field 1 tree per field_id. Now if you insert 1 new entry, other records (even not affected) will be recomputed (lft/rgt).

At any rate, there is still the problem from the starting post:

1) If you set the category parameter "Allow submit to this category" to "No", it will not display the number of records for this category anymore.

2) Subcategories do not show number of records at all

while the used query for the page gets the result for ALL categories (even subcategories).

SELECT count(rc.catid) as num, rc.catid

  FROM #__js_res_record_category AS rc

  WHERE rc.section_id = 2

  GROUP BY rc.catid

Sergey
Total posts: 13,748
18 Jun 2017 08:41

Sackgesicht while the used query for the page gets the result for ALL categories (even subcategories).

Actualy you get number of articles in section. This term is better than all categories because it shows the difference. You remember in Resources we had one table for sections and categories, and top level category was considered as section. Now it is a different tables. So it is easy to calculate total in section but still complicated in category tree branch.


Sackgesicht VIP
Total posts: 1,636
18 Jun 2017 09:24

See example:

The query on the page produces all category numbers, but does not display it for a subcategory and even for a category when parameter "Allow submit to this category" is set to "No",

Category 22 = SPA and category 52 = ATPL-Exp

2017-06-18_17-01-13

2017-06-18_17-02-48

The problem is, that the numbers are not displayed, even though they are made available by the query. If i change "SPA" parameter "Allow submit to this category" to "Yes", it will display the number again.


Sergey
Total posts: 13,748
18 Jun 2017 09:39

Find in category index template this

<?php if($params->get('tmpl_params.cat_nums') && $category->params->get('submission')):?>

And change to this

<?php if($params->get('tmpl_params.cat_nums') && ($category->params->get('submission') || $category->records_num)):?>

Sackgesicht VIP
Total posts: 1,636
18 Jun 2017 10:40

Ok, working now ... I also adjusted the display for subcategories


Sergey
Total posts: 13,748
19 Jun 2017 13:32

I added those change to next update you can safely update.

Powered by Cobalt