No Code Attached Yet
avatar uzielweb
uzielweb
14 Nov 2025

Feature Request: Add Conditional Check Before Rendering Email Form Heading in com_contact's default.php

Summary

Add a conditional if statement before the hardcoded echo of the email form heading in components/com_contact/views/contact/tmpl/default.php to allow for flexible display control, such as based on user permissions, layout parameters, or custom overrides.

Description

In the current implementation of default.php within the Joomla Contacts component (com_contact), the email form heading is rendered unconditionally using the following code:

<?php echo '<' . $htag2 . '>' . Text::_('COM_CONTACT_EMAIL_FORM') . '</' . $htag2 . '>'; ?>

This outputs a heading (e.g., <h3>Email Form</h3>) regardless of context, which can lead to unnecessary UI elements in certain scenarios, such as:

  • When the contact form is disabled or hidden via parameters.
  • In custom layouts where the heading should be suppressed.
  • For accessibility or theming needs where headings need to be dynamically controlled.

Proposed Change

Introduce a simple if condition before the echo statement to make its rendering optional. This could check against:

  • A new template parameter (e.g., $display_email_heading).
  • The form's visibility state (e.g., $this->contact->params->get('show_email')).
  • Or a more general condition like if ($this->contact->params->get('show_contact_form', 1)).

Example Implementation

<?php if ($this->contact->params->get('show_email_heading', 1)) : ?>
    <?php echo '<' . $htag2 . '>' . Text::_('COM_CONTACT_EMAIL_FORM') . '</' . $htag2 . '>'; ?>
<?php endif; ?>
  • New Parameter: Add show_email_heading to the contact form's XML parameters (default: 1) for backend control.
  • Fallback: Ensure backward compatibility by defaulting to true or using an existing related parameter.

Motivation

  • Flexibility: Allows site administrators and developers to hide the heading without overriding the entire template, reducing maintenance overhead.
  • Accessibility: Prevents redundant headings in screen readers when the form is not present.
  • Consistency: Aligns with Joomla's philosophy of parameter-driven layouts, similar to other components (e.g., com_content's article headings).
  • User Experience: Cleaner interfaces in edge cases, like single-field forms or integrated contact pages.

Potential Impact

  • Low Risk: The change is isolated to one line and uses a default that preserves current behavior.
  • Testing Required: Verify in various Joomla versions (4.x/5.x), themes, and accessibility tools.
  • Related Files:
    • components/com_contact/views/contact/tmpl/default.php (primary).
    • components/com_contact/views/contact/tmpl/form.php (if form-specific).
    • XML params in components/com_contact/contact.xml.

Alternatives Considered

  • Full template override: Works but increases fragmentation across installations.
  • CSS hiding: Not semantic; fails for non-visual users.
  • Event dispatching: Overkill for such a simple toggle.

Additional Context

If this aligns with the component's roadmap, I'd be happy to submit a PR or provide more details!

avatar uzielweb uzielweb - open - 14 Nov 2025
avatar joomla-cms-bot joomla-cms-bot - change - 14 Nov 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Nov 2025
avatar uzielweb uzielweb - change - 14 Nov 2025
The description was changed
avatar uzielweb uzielweb - edited - 14 Nov 2025
avatar brianteeman
brianteeman - comment - 14 Nov 2025

<?php if ($tparams->get('show_email_form') && ($this->item->email_to || $this->item->user_id)) : ?>

Add a Comment

Login with GitHub to post a comment