diff --git a/components/com_contact/layouts/field/render.php b/components/com_contact/layouts/field/render.php
index 3583365b3e416..051ef1c7b9025 100644
--- a/components/com_contact/layouts/field/render.php
+++ b/components/com_contact/layouts/field/render.php
@@ -16,12 +16,20 @@
return;
}
-$field = $displayData['field'];
-$label = Text::_($field->label);
-$value = $field->value;
-$class = $field->params->get('render_class');
-$showLabel = $field->params->get('showlabel');
+$field = $displayData['field'];
+$label = Text::_($field->label);
+$value = $field->value;
+$showLabel = $field->params->get('showlabel');
+$prefix = Text::plural($field->params->get('prefix'), $value);
+$suffix = Text::plural($field->params->get('suffix'), $value);
$labelClass = $field->params->get('label_render_class');
+$valueClass = $field->params->get('value_render_class');
+
+$class = $field->name;
+
+if ($field->params->get('render_class')) {
+ $class .= ' ' . $field->params->get('render_class');
+}
if ($field->context == 'com_contact.mail') {
// Prepare the value for the contact form mail
@@ -31,7 +39,7 @@
return;
}
-if (!strlen($value)) {
+if ($value == '') {
return;
}
@@ -42,5 +50,11 @@
-
+
+
+
+
+
+
+
diff --git a/components/com_contact/layouts/field/subform.php b/components/com_contact/layouts/field/subform.php
new file mode 100644
index 0000000000000..c4dc6f16e09a9
--- /dev/null
+++ b/components/com_contact/layouts/field/subform.php
@@ -0,0 +1,50 @@
+
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Language\Text;
+
+if (!array_key_exists('field', $displayData)) {
+ return;
+}
+
+$field = $displayData['field'];
+$label = Text::_($field->label);
+$value = $field->value;
+$showLabel = $field->params->get('showlabel');
+$prefix = Text::plural($field->params->get('prefix'), $value);
+$suffix = Text::plural($field->params->get('suffix'), $value);
+$labelClass = $field->params->get('label_render_class');
+$valueClass = $field->params->get('value_render_class');
+
+if ($field->context == 'com_contact.mail') {
+ // Prepare the value for the contact form mail
+ $value = html_entity_decode($value);
+
+ echo ($showLabel ? $label . ': ' : '') . $value . "\r\n";
+ return;
+}
+
+if ($value == '') {
+ return;
+}
+
+?>
+
+ :
+
+
+
+
+
+
+
+
diff --git a/components/com_contact/layouts/fields/render.php b/components/com_contact/layouts/fields/render.php
index 1f4821b5d5c74..014137820fd11 100644
--- a/components/com_contact/layouts/fields/render.php
+++ b/components/com_contact/layouts/fields/render.php
@@ -10,6 +10,8 @@
defined('_JEXEC') or die;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
// Check if we have all the data
@@ -40,30 +42,87 @@
$fields = $item->jcfields ?: FieldsHelper::getFields($context, $item, true);
}
-if (!$fields) {
+if (empty($fields)) {
return;
}
// Check if we have mail context in first element
$isMail = (reset($fields)->context == 'com_contact.mail');
-if (!$isMail) {
- // Print the container tag
- echo '';
-}
+$output = array();
+
+// Organize the fields according to their group
+
+$groupFields = array(
+ 0 => [],
+);
+
+$groupTitles = array(
+ 0 => '',
+);
-// Loop through the fields and print them
foreach ($fields as $field) {
// If the value is empty do nothing
- if (!strlen($field->value) && !$isMail) {
+ if ((!isset($field->value) || trim($field->value) === '') && !$isMail) {
continue;
}
$layout = $field->params->get('layout', 'render');
- echo FieldsHelper::render($context, 'field.' . $layout, array('field' => $field));
+ $content = FieldsHelper::render($context, 'field.' . $layout, array('field' => $field));
+
+ // If the content is empty do nothing
+ if (trim($content) === '') {
+ continue;
+ }
+
+ if (!array_key_exists($field->group_id, $groupFields)) {
+ $groupFields[$field->group_id] = [];
+
+ if (Factory::getLanguage()->hasKey($field->group_title)) {
+ $groupTitles[$field->group_id] = Text::_($field->group_title);
+ } else {
+ $groupTitles[$field->group_id] = htmlentities($field->group_title, ENT_QUOTES | ENT_IGNORE, 'UTF-8');
+ }
+ }
+
+ $groupFields[$field->group_id][] = $content;
}
-if (!$isMail) {
- // Close the container
- echo '
';
+// Loop through the groups
+
+foreach ($groupFields as $group_id => $group_fields) {
+ if (!$group_fields) {
+ continue;
+ }
+
+ if ($groupTitles[$group_id]) {
+ if ($isMail) {
+ $output[] = "\r\n" . $groupTitles[$group_id] . "\r\n";
+ } else {
+ $output[] = '';
+ $output[] = '' . $groupTitles[$group_id] . '';
+ $output[] = '';
+ }
+ }
+
+ foreach ($group_fields as $field) {
+ $output[] = $field;
+ }
+
+ if ($groupTitles[$group_id] && !$isMail) {
+ $output[] = '
';
+ $output[] = '';
+ }
+}
+
+if (empty($output)) {
+ return;
}
+?>
+
+
+
+
+
+
+
diff --git a/components/com_fields/layouts/fields/render.php b/components/com_fields/layouts/fields/render.php
index 80a8a5c4a0801..0d4ebf260c1c7 100644
--- a/components/com_fields/layouts/fields/render.php
+++ b/components/com_fields/layouts/fields/render.php
@@ -10,6 +10,8 @@
defined('_JEXEC') or die;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
// Check if we have all the data
@@ -46,13 +48,28 @@
$output = array();
+// Organize the fields according to their group
+
+$groupFields = array(
+ 0 => [],
+);
+
+$groupTitles = array(
+ 0 => '',
+);
+
foreach ($fields as $field) {
// If the value is empty do nothing
if (!isset($field->value) || trim($field->value) === '') {
continue;
}
- $class = $field->name . ' ' . $field->params->get('render_class');
+ $class = $field->name;
+
+ if ($field->params->get('render_class')) {
+ $class .= ' ' . $field->params->get('render_class');
+ }
+
$layout = $field->params->get('layout', 'render');
$content = FieldsHelper::render($context, 'field.' . $layout, array('field' => $field));
@@ -61,7 +78,40 @@
continue;
}
- $output[] = '' . $content . '';
+ if (!array_key_exists($field->group_id, $groupFields)) {
+ $groupFields[$field->group_id] = [];
+
+ if (Factory::getLanguage()->hasKey($field->group_title)) {
+ $groupTitles[$field->group_id] = Text::_($field->group_title);
+ } else {
+ $groupTitles[$field->group_id] = htmlentities($field->group_title, ENT_QUOTES | ENT_IGNORE, 'UTF-8');
+ }
+ }
+
+ $groupFields[$field->group_id][] = '' . $content . '';
+}
+
+// Loop through the groups
+
+foreach ($groupFields as $group_id => $group_fields) {
+ if (!$group_fields) {
+ continue;
+ }
+
+ if ($groupTitles[$group_id]) {
+ $output[] = '';
+ $output[] = '' . $groupTitles[$group_id] . '';
+ $output[] = '';
+ }
+
+ foreach ($group_fields as $field) {
+ $output[] = $field;
+ }
+
+ if ($groupTitles[$group_id]) {
+ $output[] = '
';
+ $output[] = '';
+ }
}
if (empty($output)) {