Skip to main content

Timeline for J4. Get children categories

Current License: CC BY-SA 4.0

5 events
when toggle format what by license comment
Apr 18, 2023 at 13:50 comment added Sharky In the second snippet you do not write child categories to a variable. $categories is still an instance of Joomla\CMS\Categories\Categories. I updated the answer to include full code from your question, in case that makes it clearer. Essentially, nothing changes, except the first part.
Apr 18, 2023 at 13:50 history edited Sharky CC BY-SA 4.0
Update with code from question for context
Apr 18, 2023 at 11:39 vote accept Peli
Apr 18, 2023 at 11:38 comment added Peli Thanks Sharky, It's what I was looking for. I have a strange behavior: $categories = $component->getCategory()->get($catId)->getChildren(true); gives subcategories of $catId , but $categories = $component->getCategory(); $categories->get($catId)->getChildren(true); returns empty. It's right? I am doing something wrong?
Apr 18, 2023 at 7:08 history answered Sharky CC BY-SA 4.0