Feature No Code Attached Yet
avatar brianteeman
brianteeman
27 May 2025

Steps to reproduce the issue

Create two categories
Parent
Parent->child

Create one field and assign it to the Parent Category

Expected result

Field is only available to articles in the parent category

Actual result

Field is available to articles in the parent and child category. There is no way to assign a field just to the parent category

System information (as much as possible)

Additional comments

avatar brianteeman brianteeman - open - 27 May 2025
avatar joomla-cms-bot joomla-cms-bot - change - 27 May 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 May 2025
avatar chmst chmst - change - 27 May 2025
Labels Added: Feature
avatar chmst chmst - labeled - 27 May 2025
avatar brianteeman
brianteeman - comment - 6 Jun 2025

So I just took a look at this and the "problem" is that the code is specifically written to include child categories. (does anyone know why - it's not something I see elsewhere in Joomla)

The relevant code is

if ($cat) {
foreach ($categories as $assignedCatIds) {
// Check if we have the actual category
$parent = $cat->get($assignedCatIds);
if ($parent) {
$categories[] = (int) $parent->id;
// Traverse the tree up to get all the fields which are attached to a parent
while ($parent->getParent() && $parent->getParent()->id != 'root') {
$parent = $parent->getParent();
$categories[] = (int) $parent->id;
}
}
}
}

When I remove that block of code I can successfully assign a field to

  1. Parent only
  2. Child only
  3. Parent & Child
  4. All

The problem is that this would be a b/c break so we cant just delete the block of code and would need to place it behind a param (include/exclude children) with the default being include

and should this include/exclude child categories be per field or a global option for com_fields

thoughts?

Add a Comment

Login with GitHub to post a comment