Category Implementation - Nested Categories #260
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: joomla/Component-Builder#260
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Steps to reproduce the issue
Create a category in, as an example, Sermon Distributor, then add some child categories. Such as:
Sunday Class
Now, add a sermon to Class 1 and Class 2. On the frontend of your website, it you display items from the category for Class 1 or Class 2 categories, then it should the item in that category. However, if you select the parent, Sunday Class, nothing displays, since there is nothing in "Sunday Class".
Expected result
If you selected a parent category it would load all items in the parent category, as well as all child categories. Basically, everything between lft and rgt. com_categories has various categories, but the way Joomla implemented it, the lft and rgt columns contain the range to encompass that. For example, Sunday Class id=71, Class 1 id=72, and Class 2 id=73.
However, in the database, lft on Sunday Class is 73, rgt=78. Class 1 is 74 and 75, and Class 2 is 76 and 77.
An explanation of the process that Joomla implemented can be understood here: https://www.sitepoint.com/hierarchical-data-database-2/
Basically, in part, it is the implementation of /libraries/src/Table/Nested.php
com_content is an example of how Joomla implemented this feature to show items from a parent category, as well as child categories.
Actual result
JCB only displays items from the selected category, not parent and child categories.
System information (as much as possible)
Additional comments
Since the whole front-end query is build by you, via a dynamic get. Dealing with child categories is really up to each developer.
Sermon Distributor does not deal with it in the same way that you are expecting, but you can set it up by combining a getItem (main-get) and a getCustoms. Since the dynamic get can load multiple queries on one page. One main-get and many custom gets...
I should at some point make a tutorial of some of the advanced combinations that can be done.
But for now the short answer is, that kind of query can be build, but you will have to combine a few queries with the
Tweak->Filter->FunctionVar
andTweak->Set Global
to make the connection between queries.The
State Key
could be something like$this->a_parent
and theTable Key
would then bea.parent_id
in the getCustoms(getChildren) query.The
name
must then beparent
and theTable Key/As Name
must beid
and theAS
isa
and thetype
isthis
You will then get the children of the parent on the same page, yes it will be in a different object, but could easy link echo them based on parent ID.
Hope this helps. The query combination features of JCB is absolutely mind blowing, but yes not always obvious.
Let me know if you have any further questions on this.