A
B
and select parent category to A
so the category tree looks like this: A -> B
Test
and as a category select both A
and B
. Then in Options
tab select Automatic Display
to Before Content
Test Article
in B
category and fill Test
field with with: This is the test field
B
categoryTest Article
and open it.This article Test
field should only be visible once
Field is duplicated
3.9.4 but I'm pretty sure it goes back to the introduction of custom fields
I investigated the matter and it is caused by incomplete query in FieldsModelFields
model (method getListQuery
) from /administrator/components/com_fields
. There is no group by in the query so field will be duplicated as many times as the number of parent categories on which your custom field exists. So if your tree is like A -> B -> C -> D and you place the article in D with setting the custom field to be available in all 4 categories you will have this field displayed 4 times. Simple group by should do the trick. It exists in content component but I'm pretty sure it affects all components using custom form fields and categories.
Status | New | ⇒ | Discussion |
Labels |
Added:
J3 Issue
|
Confirmed, e.g. you have field assigned to category D
If you also assign field to the (ancestor) categories A,B,C (see picture)
Then you will get field values to appear 4 times when viewing the article in category D because,
there is no group-by (or other solution) in the getListQuery() as the description says
// Join over the assigned categories
$query->join('LEFT', $db->quoteName('#__fields_categories') . ' AS fc ON fc.field_id = a.id')
results in joining with the __fields_categories table 4 times, and getting same field 4 times
I would look for another solution than using group-by. Groups are meant to use aggregate functions on the grouped rows. We don't need that.
A better approach is using DISTINCT.
Well in this situation GROUP BY or DISTINCT makes no difference. Its just internal way of finding fields. So Just use the faster one?
GROUP BY also means you need to add each selected column (that doesn't contain different values) to the GROUP BY command.
DISTINCT is much simpler as you can just specify one column.
So at least the code gets simpler with DISTINCT
for me the issue is here https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_fields/models/fields.php#L209
why
// Traverse the tree up to get all the fields which are attached to a parent
?
closed as having a Pull Request.
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-04-06 07:25:27 |
Closed_By | ⇒ | franz-wohlkoenig |
@artur-stepien please test #24516
i'm unable to replicate if i understand this issue correctly
