EPT Title Field WYSIWYG causing paragraph in H2

Created on 9 July 2024, 6 months ago
Updated 18 July 2024, 5 months ago

Problem/Motivation

When using the EPT Title Field for a container/column, the field uses a WYSYWIG editor, but this causes the text to automatically be wrapped in a paragraph which would result in a <p> within an <h2> (since the template file already outputs the title within an h2 by default).

<h2>
    <div class="clearfix text-formatted field field--name-field-ept-title field--type-text-long field--label-hidden field__item">
        <p>Explore CMS</p>
    </div>      
</h2>

This probably isn't good semantically in HTML.

Steps to reproduce

Create a new EPT container and add some text in the Title field.

Proposed resolution

Perhaps it might be best to have the title as a plain text field. That way when it gets output in the paragraph--ept-columns--default.html.twig template. it will just appear as plain text in the h2 instead of a paragraph within the h2.

Remaining tasks

N/A

User interface changes

Switch from a WYSIWYG editor to plain text field.

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Fixed

Version

1.4

Component

User interface

Created by

🇯🇲Jamaica axle_foley00

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @axle_foley00
  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia

    Hi axle_foley00, I thought a lot about how to achive titles with ability to add formatting, links, small images, etc. And keep it semantically good. I thought to use Fences module and make it sematically better:
    https://www.drupal.org/project/fences

    But then fields configs became too big and complicated, installation EBT/EPT modules will affect on other content types, paragraph types and block types, because Fences will be everywhere. I refused an idea to use Fences, but it's still possible to use it for any EBT/EPT modules.

    I also thought to remove hardcoded

    tags from templates, and add

    tags in CKEditor as Header style. I used this approach on few commercial projects and it's working fine. But it's not obvious for regular editors, why Title field is not becoming

    automatically.

    Also I thougt to use Fences modules to set field wrapper H2 tag, but sometimes it's needed to use H3 or H4 tags instead for block titles.

    I can add additional settings field Title Tag checkbox or select list with H2, H3, H4, None, options and display title tag based on this option.

    If you have any ideas, feel free to share them. I will be glad to hear any feedback.

  • 🇯🇲Jamaica axle_foley00

    Hey @levmyshkin,

    Okay I understand your motivation now for having things the way they currently are. The use case of being able to quickly add an image/icon with the Title is a useful one. I had a project that required something like that but I just decided to add those icons beside the titles as a background image using CSS.

    I do agree that ideally we wouldn't want to make the configs too big and complicated.

    I'm wondering if adding an option similar to the Style settings in Views could work. So as you said, have the select list with the options H2, H3, H4, None, etc.. and then display based on that.

  • Assigned to rohitsharma401
  • 🇮🇳India rohitsharma401

    we can use
    |replace({'

    ': '', '

    ': ''})
    directly in the twig file where we are rendering.

    The replace filter is used to remove specific HTML tags.{'

    ': '', '

    ': ''} specifies that any

    tags and their corresponding closing

    tags should be replaced with an empty string, effectively removing them.

    I will add a patch file for this.

  • Issue was unassigned.
  • Status changed to Needs review 5 months ago
  • 🇮🇳India rohitsharma401

    i have done this directly in the Twig template where in the title field at the time of rendering .

  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia

    Hi rohitsharma401, thank you for your patch, but we need to solve another problem, we should avoid

    tags inside

    tags.

    Here is a discussion about removing extra divs:
    https://www.drupal.org/forum/support/theme-development/2022-07-27/fixed-...

    And even here is potential problems with Quick editing, possibly for Mercury Editor too:
    https://www.drupal.org/project/mercury_editor
    https://www.drupal.org/project/quickedit

    Looks promising by the way, quick editing is needed only for editors and Google will not see page with additional

    wrappers for quick editing.
    • levmyshkin committed 153b9869 on 1.4.x
      Issue #3460287 by axle_foley00: EPT Title Field WYSIWYG causing...
  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia

    Hi axle_foley00, I added new Title Options for EPT settings:


    It's going to strip tags by default and show only h2 tag (optionally too). You will need to update EPT Core, EPT Columns and re-save EPT paragraphs on your site.

    It's still possible to use <br>, <img>, <i>, <span> for settings styles and multiple lines for title.

    I will update all other EPT modules eventually too.

  • Status changed to Fixed 5 months ago
  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia
  • Status changed to Fixed 5 months ago
  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia
  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia

    By the way, it will brake Quick Editing, but I'm good for now with this solution, since Mercury is not working with CKEditor 5, it's not usable for now.

  • 🇯🇲Jamaica axle_foley00

    @levmyshkin and @rohitsharma401, okay great thanks! I'll update the modules in my install to get the new changes.

Production build 0.71.5 2024