filtering out H2 elements

Created on 26 April 2023, about 1 year ago
Updated 17 May 2023, about 1 year ago

Problem/Motivation

Trying to filter out H4 items.

Steps to reproduce

Can I pick your brains please? I am working with a low-tech editorial staff. They manage to publish texts and add h1, h2 tags. Great.
For further accessibility, I would like to convert these h2 tags into destination anchor links. Also possible.
Via Views I wanted to make a block showing all anchor links in the text (rewriting these into source links).

Would it be possible in Views to take a full html text, and only show or rewrite the h2 tagged pieces of text? How?

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

💬 Support request
Status

Closed: works as designed

Version

9.5

Component
Views  →

Last updated 1 minute ago

Created by

🇳🇱Netherlands jandewit6

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

Comments & Activities

  • Issue created by @jandewit6
  • 🇮🇳India Prashant.c Dharamshala

    @jandewit6
    Could you please provide us with some examples of your requirement?

  • 🇳🇱Netherlands jandewit6

    In the text below, I include H4 elements.
    Question: in a View, how could I show the H4 text only and omit the [

    ]text?

    Paragraph 1

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ultricies vel massa vel congue. Cras dignissim, felis eu sollicitudin finibus, libero est ultrices tortor, ac vulputate ante ipsum sit amet risus. Nam magna ipsum, sagittis euismod dui vel, ultricies sodales augue. Cras elementum sit amet sapien sit amet tincidunt.

    Paragraph 2

    Vestibulum volutpat rutrum consectetur. In blandit non felis ut facilisis. Donec tempor tellus at sodales rutrum. Fusce vitae tincidunt ex. Curabitur ut porttitor felis. Cras ornare sem vel leo commodo lobortis.

    Paragraph 3

    Phasellus viverra nunc eu malesuada malesuada. Maecenas sollicitudin quis augue id placerat. Morbi sit amet tellus vitae neque pellentesque vulputate. Mauris tortor enim, dictum eu libero sit amet, dictum dignissim mauris. Integer euismod in nulla quis malesuada. Donec posuere felis eget sapien tempus posuere. Proin non orci a neque commodo dictum ut vel purus.

  • 🇳🇱Netherlands jandewit6

    Just found out that there are modules for my use case: https://www.drupal.org/project/table_of_contents →

    Although I prefer the Views approach and be completely independent of modules, for now I implemented this toc module.

    Any thoughts on the Views approach still appreciated!

  • Status changed to Closed: works as designed about 1 year ago
  • 🇳🇱Netherlands Lendude Amsterdam

    Views only really works well with structured fields. So if you would use Paragraphs for these blocks of text and the title text is in a different field than the block text, that could work, (so in this example it would be 3 Paragraph items with 2 fields each).

    Doing invasive rewriting will get really messy really quickly in my experience (if it works at all).

    Using that module seems like the right way of doing things here.

  • 🇳🇱Netherlands jandewit6

    Thanks.
    I agree on the structuring of fields. However, in working with volunteers who work quite unstructured, one has to come up with solutions.

    The mentioned module (there is a module for that!) has the problem of messing with layout builder.

    Anyhow, works for now.

Production build 0.69.0 2024