jDownloads for Joomla 3.x => jDownloads 3.9 => Bugs => Topic started by: WernerF on 01.09.2021 20:04:34

Title: Bug and fix with view_empty_categories[solved in]
Post by: WernerF on 01.09.2021 20:04:34
This forum thing does not seem to accept my RETURN key. Really bad for writing and bad for those who must read this. Sorry I can't help it.

I encountered very bad behaviour with missing categories in the pull down list in 3.9. Well, you have a typo in the following to files: views/category/tmpl/default.php and views/download/tmpl/default.php.
Please change get('view_empty_categories, 1') into get('view_empty_categories', 1).
If you don't see the difference  immediately, the string is wrong because the comma and the 1 are part of the string.

Please also correct administrator/components/com_jdownloads/config.xml. Someone has commented out the field with name="view_empty_categories",   added a comment that there was a problem which they couldn't fix and added a hidden and hard-coded value instead which was never tested and does not work.
I think the problem is the understanding of an empty category. In the current implementation  a category is considered empty if it has no files in it. But that's wrong because it can still have subcategories in it. And that's when the display in the pull down list get's weird if you swith off the display of empty categories. Instead, a category should only be considered empty if it has both no files and no subcategories. Only in this case it might make sense to switch its display of.
Therefor you must change your SQL which fills the list.

Hope this helps.
Title: Re: Bug and fix with view_empty_categories
Post by: ColinM on 04.09.2021 20:54:50
Thanks for your inputFirst the simple bit - in the forum to get the Retun key to work click on the [k] symbol.One day when we get a chance the intent is to move to another Forum code but ....
The items about the two typos were fixed in jd3.9.8.1  - Your notes were most helpful. 
The more interesting item is about administrator/components/com_jdownloads/config.xml.  It was commented out as a 'quick fix'. It is recognised that the database code needs to be more 'comprehensive'.  It is not a simple change and remains on the 'to do' list.  The pressure is to get a version of jD that works with Joomla! 4 and this is consuming much effort from Arno with assist from myself.For convenience consider that the Downloads are 'leaves' on the branches of a tree.  Within that context an empty category is a branch with no leaves.  It is not always obviuos where the  'category' is where that branch starts

In the attached image clearly subcat 'sub3-2-2-1 has no downloads so should not be shown. Similarly subcat 'sub 2-1' has no Downloads but also it parent 'Cat2' whilst having a sub category , does not lead to a Download.  So 'Cat2' should not be shown.A further complication is does the user have Acces (as I prefer to call it view Access) to see the 'category and its downloads.So determining what will be shown is not a simple choice.Any further thouights appreciated.Colin
Title: Re: Bug and fix with view_empty_categories
Post by: WernerF on 04.09.2021 23:20:41
Hi Colin,
I have on my system and I had to find and fix the typos there. You must be talking about a newer version I think.
I agree on your priorities. Didn't want to push you, just wanted to make shure you have a fix for the obvious bugs and rethink the strategy of obsolete categories not to show.
While I also agree on your actual examples with empty categories I did have problems with categories not being shown when they should be shown.
Take your tree example. In version cat3 and sub3-2 would both not be shown (because view_empty_categories=1 was ignored). Thats a problem even with view_empty_categories=0 because the actual display is a pull down list and not a tree. So the pull down list would be as follows:
You see that the user must think both sub3-2-1 and sub3-2-2 are childs of sub3-1 and sub3-1 is a child of cat1 which is all wrong. He also has no clue that everythinig down from sub3-1 belongs to cat3 and not to cat1.
So the user has no chance of understanding the tree behind it.
I think you MUST show both cat3, and sub3-2, because they do have valid child-leaves. Only the the user can understand the hirarchy and the list must look like this:
-- sub3-2-1
-- sub3-2-2
- sub3-3
The only leaves you may hide are cat2, sub2-1 and sub3-2-2-1 because they have no valid downloads as (grand grand...) children and only if view_empty_categories=0
Currently for example cat3, and sub3-2 are not shown which leads to an ununderstandable list for the user.
I agreee that the problem shows up only if view_empty_categories=0, so the hidden field makes sense as long as this topic is not fixed. But the current workaround in the xml did not work because the whole parameter was ignored due to the 2 typos. Hence the system took it always as view_empty_categories=0.

But wait, there is another bad consequence if view_empty_categories=0:
If you start at root and walk through the hirarchy clicking on the icons and names, whenever you click a (sub) category which is missing in the pull down list the root item is hilighted because the actually selected one is not there. That's how you get totally lost and confused with the pull down list and you really don't know where you are any more. In fact, you can't even jump back to the root again from the pull down list because root is already highlited although you are in a sub branche and clicking on root does nothing.

With my fix I was able to use view_empty_categories=1 correctly and that helped me.
Hope I was clear and this might help y'all.

Title: Re: Bug and fix with view_empty_categories
Post by: ColinM on 05.09.2021 11:21:10
 The objective of the little image was to show what needs to happen, not what is happening!

Apart from the two typos you indicated you had a working solution. If so could you use a PM (Private Message) by clicking on the little white square with a small tail just below my name -see pic