Hello,
I would like to insert articles into a newsletter and output values from subform fields.
When I now select a subform field in the editor, only the pure JSON array is output in the email and not the actual values.
I found the code in the file administrator/components/com_acym/libraries/plugin.php that is responsible for the output of the custom fields. But there is only an output for the old "repeater" fields (line 810).
When I insert the following code into the getFormattedValue method, the output works as desired:
case 'subform':
if (!empty($field->value)) {
$values = json_decode($field->value);
foreach ($values as $oneSetOfValues) {
foreach ($oneSetOfValues as $oneValue) {
$formattedSet[] = $oneValue;
}
}
$field->value = '<span>'.implode('</span><span>', $formattedSet).'</span>';
}
break;
Now, of course, I cannot overwrite the core files, as the change will be lost in the next Acymailing update.
Therefore, I created a "subform" plugin in the "dynamics" folder and also installed it in the database.
The plugin should overwrite the getFormattedValue method, but it does not work. Even my simple test code is not executed:
<?php
use AcyMailing\Libraries\acymPlugin;
class plgAcymGfsubform extends acymPlugin
{
protected function getFormattedValue(&$fieldValues)
{
return 'Subform Test';
}
}
Why is the method not correctly overwritten? Why doesn't my code work? Sorry, I'm not really a PHP expert. Thank you very much for your help.