1/ create a custom field for an article
2/ create a custom field for a contact
both fields have the same html output
both fields are rendered differently.
<dd class="field-entry">
<span class="field-label">test: </span>
<span class="field-value">here is my test</span>
</dd>
<dt class="contact-field-entry">
<span class="field-label">test: </span>
</dt>
<dd class="contact-field-entry">
<span class="field-value">here is my test</span>
</dd>
Joomla 3.7
In my opinion, we shall keep the same structure for all custom fields and not have so much difference. Here not only that the css classes are different, also the HTMl is different
We should use something like this which is more general and flexible
<dd class="field-entry contact-field-content">
<span class="field-label">test: </span>
<span class="field-value">here is my test</span>
</dd>
<dd class="field-entry contact-field-contact">
<span class="field-label">test: </span>
<span class="field-value">here is my test</span>
</dd>
thanks for your answer. In my mind by default we shall have a structure that is common to all components. Then the developpers/integrators can use the overrides to do what they want of course.
Now for example if I want to style the fields in my website, I have to use multiple css rules depending on how joomla renders them in each page. This is not correct I think
Having by default an override has no sense for me
Really, making things simpler would be great :)
My code suggestion in the contact JLayout override
in
components/com_contact/layouts/field
<?php
/**
if (!key_exists('field', $displayData))
{
return;
}
$field = $displayData['field'];
$label = $field->label;
$value = $field->value;
$class = $field->params->get('render_class');
$showlabel = $field->params->get('showlabel');
if (!$value)
{
return;
}
if ($field->context == 'com_contact.mail')
{
// Prepare the value for the contact form mail
echo $label . ': ' . $value . "\r\n";
return;
}
?>
<dd class="field-entry contact-field-entry <?php echo $class; ?>">
<?php if ($showlabel == 1) : ?>
<span class="field-label"><?php echo htmlentities($label, ENT_QUOTES | ENT_IGNORE, 'UTF-8'); ?>: </span>
<?php endif; ?>
<span class="field-value"><?php echo $value; ?></span>
</dd>
Since you already propose some code, can you try making a Pull Request?
Some documentation can be found here: https://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests
Status | New | ⇒ | Discussion |
Closed as I made a PR for the above change.
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-08-20 11:10:13 |
Closed_By | ⇒ | brianteeman |
Contact has an override for the field JLayout. So this is expected to be different due to different JLayouts being used.
Of course trying to make them consistent would be great.