jDownloads Support Forum

jDownloads for Joomla 4.x and 5.x => jDownloads 4.0 => Bugs! => Topic started by: michpaule on 13.04.2023 11:30:26

Title: Custom fields not loaded ($item->jcfields) - [Fixed in 4.0.25]
Post by: michpaule on 13.04.2023 11:30:26
Problem:
{jdfield_title ID} and {jdfield ID} always empty.

Tested on:
jDownloads Versions 3.9.8.7 and 4.0.24

See related report:
https://www.jdownloads.com/forum/index.php?topic=12898.0

Observation:
jcfields array always empty.
Example:
            // Insert the Joomla Fields data when used
            if (isset($items[$i]->jcfields) && count((array)$items[$i]->jcfields)){


Workaround:
Patch function getItems() in /components/com_jdownloads/src/Model/DownloadModel.php (or downloads.php for 3.9)
            // Get the tags
            $item->tags = new TagsHelper;
            $item->tags->getItemTags('com_jdownloads.download', $item->id);

            // Populate jcfields
            $item->jcfields = FieldsHelper::getFields('com_jdownloads.download', $item, true);
           
            // Build the multilingual association hints
            if ($item->params->get('show_associations')){
                $item->associations = AssociationHelper::displayAssociations($item->id);
            }           


@Arno: Could it really be the case that this problem has been in the code for so long?
Or did I miss something?

Best regards

Michael
Title: Re: Custom fields not loaded ($item->jcfields)
Post by: Arno on 14.04.2023 19:10:17
Hi,
thanks for this bug report.

I have no idea why I had always overlooked this before. Sorry.
It's fixed now in jD 4.