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!
Tried everything, but missing something please help me
Thanks
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
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.
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.
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;
}
@giudansky As Hannes said, you have to use rawvalue:
$myFields[$field->name] = $field->rawvalue;
Labels |
Added:
Information Required
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-08-21 14:27:20 |
Closed_By | ⇒ | Hackwar |
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.
Take a look at cleanImagueURL in the for developers section #30784