No Code Attached Yet Information Required
avatar giudansky
giudansky
2 Aug 2023

I'm updating my J3/J4 template which uses the media type custom fields in a subform, exactly with the new metadata you're reporting.

I'm getting my custom field including the media type, JSON decoding it as I always did. (And as it still seems to be the way):
$rawData = json_decode($myFields['image-gallery'], true);

The problem is $rawdata always result "$rawData is not set". Json in the db is plain and correct.
Echoing $myFields['image-gallery'] without decoding, prints out an "ul class=fields-container li" list with the media images, so everything is there. This is strange because i'm expecting to get my raw json data!
screen shot 2023-08-02 at 06 25 48

Tried everything, but missing something please help me

Thanks

avatar giudansky giudansky - open - 2 Aug 2023
avatar giudansky giudansky - change - 2 Aug 2023
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 2 Aug 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 2 Aug 2023
avatar giudansky giudansky - change - 2 Aug 2023
The description was changed
avatar giudansky giudansky - edited - 2 Aug 2023
avatar giudansky giudansky - change - 2 Aug 2023
The description was changed
avatar giudansky giudansky - edited - 2 Aug 2023
avatar brianteeman
brianteeman - comment - 2 Aug 2023

Take a look at cleanImagueURL in the for developers section #30784

avatar giudansky
giudansky - comment - 2 Aug 2023

I saw it. But the problem looks like I can't decode json. I'm only able to echo the subform with media custom field, resulting in a ul li render but no raw data.
Json decode does not work. When i'll be able to get the raw data for sure I will use cleanImageURL, but it seems to be a problem before that.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/41306.
avatar Hackwar
Hackwar - comment - 7 Aug 2023

Where do you get your $myFields from? It looks like that array is built from the ->value attributes of the fields and not ->rawvalue. The former contains a pre-rendered version of the data, the later contains the raw data.

avatar giudansky
giudansky - comment - 7 Aug 2023

I'm getting custom fields in this way:

// GET CUSTOM FIELDS
use \Joomla\Component\Fields\Administrator\Helper\FieldsHelper;

$jcfields = FieldsHelper::getFields('com_content.article', $this->item, true);
$myFields = array();
foreach ($jcfields as $field) {
	$myFields[$field->name] = $field->value;
}
avatar richard67
richard67 - comment - 18 Aug 2023

@giudansky As Hannes said, you have to use rawvalue:

$myFields[$field->name] = $field->rawvalue;

avatar Quy Quy - change - 18 Aug 2023
Labels Added: Information Required
avatar Quy Quy - labeled - 18 Aug 2023
avatar Hackwar Hackwar - change - 21 Aug 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-08-21 14:27:20
Closed_By Hackwar
avatar Hackwar Hackwar - close - 21 Aug 2023
avatar Hackwar
Hackwar - comment - 21 Aug 2023

As said, you are getting the data from the wrong place. So I'm closing this here. If you feel like this has been closed wrongly, please respond again and we'll open it again.

Add a Comment

Login with GitHub to post a comment