Skip to content

Navigating UI resources #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 5.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions docs/design/navigating_resources.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
Views
=====

Views in Mautic use a consistent naming pattern to help you organize and locate templates efficiently.

- list: View and manage all objects in a table format, such as contacts or campaigns. This page provides an overview and allows you to take actions on multiple items.

Check warning on line 6 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Landing Page' instead of 'page'. Raw Output: {"message": "[Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Landing Page' instead of 'page'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 6, "column": 92}}}, "severity": "INFO"}

Check warning on line 6 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Campaigns' instead of 'campaigns'. Raw Output: {"message": "[Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Campaigns' instead of 'campaigns'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 6, "column": 76}}}, "severity": "INFO"}

Check warning on line 6 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Contacts' instead of 'contacts'. Raw Output: {"message": "[Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Contacts' instead of 'contacts'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 6, "column": 64}}}, "severity": "INFO"}

Check warning on line 6 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Google.Colons] ': V' should be in lowercase. Raw Output: {"message": "[Google.Colons] ': V' should be in lowercase.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 6, "column": 7}}}, "severity": "WARNING"}
- details: Access detailed information about a single object, such as a contact profile. You see all available data and related actions for the specific item.

Check warning on line 7 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Contact' instead of 'contact'. Raw Output: {"message": "[Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Contact' instead of 'contact'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 7, "column": 73}}}, "severity": "INFO"}

Check warning on line 7 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Google.Colons] ': A' should be in lowercase. Raw Output: {"message": "[Google.Colons] ': A' should be in lowercase.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 7, "column": 10}}}, "severity": "WARNING"}
- form: Enter or update information for a single object, such as creating or editing a contact. You fill in required fields and submit your changes.

Check warning on line 8 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Contact' instead of 'contact'. Raw Output: {"message": "[Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Contact' instead of 'contact'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 8, "column": 88}}}, "severity": "INFO"}

Check warning on line 8 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Google.Colons] ': E' should be in lowercase. Raw Output: {"message": "[Google.Colons] ': E' should be in lowercase.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 8, "column": 7}}}, "severity": "WARNING"}

Check warning on line 8 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Form' instead of 'form'. Raw Output: {"message": "[Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Form' instead of 'form'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 8, "column": 3}}}, "severity": "INFO"}

These templates might have parts splitted into different files, for example, the list template might have a ``_list.html.twig`` file for the table and a ``_list_actions.html.twig`` file for actions.

Check failure on line 10 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'splitted'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'splitted'?", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 10, "column": 34}}}, "severity": "ERROR"}
Details templates might have an associated Details folder with files for each tab contents to help with organization and maintainability.

Platform templates
------------------

Mautic provides several Twig templates to help you streamline development and maintain consistency. Templates are organized by their purpose and functionality.

Check warning on line 16 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Google.Passive] In general, use active voice instead of passive voice ('are organized'). Raw Output: {"message": "[Google.Passive] In general, use active voice instead of passive voice ('are organized').", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 16, "column": 111}}}, "severity": "INFO"}

You will find these main folders:

- ``@MauticCore/Helper`` contains templates for common tasks, such as rendering buttons for page actions.
- ``@MauticCore/Components`` includes templates that implement design patterns from the design system for a wide variety of content.
- ``@MauticCore/Modules`` provides templates that combine Components for specific content types, such as using tile components to display statistics.

You will also find module folders inside specific bundles for templates unique to that bundle. These templates are not intended for reuse across other bundles.

.. note::

Use existing platform templates to maintain consistency and reduce code duplication.

Modifying templates
^^^^^^^^^^^^^^^^^^^

Allowing custom attributes
""""""""""""""""""""""""""

Before you add, remove, or change variables in a template, first check whether you can accomplish your goal by supporting custom attributes. Many Mautic templates already allow you to pass custom attributes, which lets you adapt behavior or appearance without changing the template’s structure. This approach works well when you need to integrate with JavaScript libraries such as Bootstrap.

You can allow custom attributes by adding this snippet to your template:

.. code-block:: twig

{% if attributes is defined and attributes is not empty %}
{% for attr_key, attr_value in attributes %}
{{ attr_key }}="{{ attr_value }}"
{% endfor %}
{% endif %}

When you include your template, pass the attributes as follows:

.. code-block:: twig

{% include '@MauticCore/Components/clickable-component.html.twig' with {
'content': 'Open Modal',
'icon': 'fa fa-external-link',
'attributes': {
'data-toggle': 'ajaxmodal',
'data-target': '#HelpModal',
'data-header': 'Modal Title'
}
} %}

Changing template structure
"""""""""""""""""""""""""""

Templates power features throughout the platform. When you change a variable or structure in a template, you affect every place that uses it. Consider the impact before making changes.

You have several options:

1. Update all usages to work with the new structure.
2. Create a new template with your changes, and add a deprecation notice to the old template. Use the new template instead of the original.
3. Add support for custom attributes if that satisfies your needs.

.. note::

Use a platform template instead of custom HTML whenever possible. If a pull request adds a button with raw HTML, reviewers require you to switch to a platform template.

Naming and organization of templates
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

When naming templates, it's important to follow the same naming pattern used by the platform. This makes it easier for other developers to understand the purpose of the template and to find it when needed.

Names must indicate the part of the UI they're responsible for.

Template naming and organization best practices
"""""""""""""""""""""""""""""""""""""""""""""""

Use consistent and descriptive naming for your templates to make them easy to locate and understand. Organize related partial templates into subfolders to improve clarity, especially when a single view includes multiple partials.

Check failure on line 87 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'subfolders'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'subfolders'?", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 87, "column": 142}}}, "severity": "ERROR"}

Previous template organizations often placed partial templates in the same folder as their parent view, using a leading underscore to identify partials. For example, the ``@MauticPage/Page/`` folder included:
- list.html.twig

Check failure on line 90 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'HTML' instead of 'html'. Raw Output: {"message": "[Vale.Terms] Use 'HTML' instead of 'html'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 90, "column": 8}}}, "severity": "ERROR"}
- form.html.twig

Check failure on line 91 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'HTML' instead of 'html'. Raw Output: {"message": "[Vale.Terms] Use 'HTML' instead of 'html'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 91, "column": 8}}}, "severity": "ERROR"}
- details.html.twig

Check failure on line 92 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'HTML' instead of 'html'. Raw Output: {"message": "[Vale.Terms] Use 'HTML' instead of 'html'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 92, "column": 11}}}, "severity": "ERROR"}
- _list.html.twig

Check failure on line 93 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'HTML' instead of 'html'. Raw Output: {"message": "[Vale.Terms] Use 'HTML' instead of 'html'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 93, "column": 9}}}, "severity": "ERROR"}

The file ``_list.html.twig`` served as a partial for rendering tables within the list view.

With the current standard, group all partials for a specific view inside a subfolder named after the parent template. Rename partials to follow a clear pattern, and remove the leading underscore. For instance, in ``@MauticPage/Page/``, organize files as follows:

Check failure on line 97 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'subfolder'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'subfolder'?", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 97, "column": 76}}}, "severity": "ERROR"}
- list.html.twig

Check failure on line 98 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'HTML' instead of 'html'. Raw Output: {"message": "[Vale.Terms] Use 'HTML' instead of 'html'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 98, "column": 8}}}, "severity": "ERROR"}
- form.html.twig

Check failure on line 99 in docs/design/navigating_resources.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'HTML' instead of 'html'. Raw Output: {"message": "[Vale.Terms] Use 'HTML' instead of 'html'.", "location": {"path": "docs/design/navigating_resources.rst", "range": {"start": {"line": 99, "column": 8}}}, "severity": "ERROR"}
- details.html.twig
- List/list--table.html.twig

Move the partial ``_list.html.twig`` to ``List/list--table.html.twig``. This approach organizes partials for the list view under the ``List`` subfolder, making it easier to locate and understand their context.

Apply similar patterns to other UI elements. For example, organize tab partials as ``Details/details--tab-overview.html.twig`` within a ``Details`` subfolder. For module templates, create a ``Modules`` folder under the appropriate bundle, such as ``app/bundles/[Name]Bundle/Resources/views/Modules/``, and use descriptive names like ``module--preview.html.twig``.

Consistent and descriptive naming conventions help you and your team quickly find and identify templates, improving maintainability and collaboration.

.. note::

Mautic is actively updating templates to follow this organization standard. Some templates still use the older structure, and the transition will continue over time.
Loading