Regex: Allow <title> tag to be replaced in segment text

Created on 10 October 2023, about 1 year ago
Updated 2 March 2024, 9 months ago

Hi everyone,

Thank you very much for the great module and documentation.

While working on a project, which uses the Easy Breadcrumb β†’ module ('2.0.5') for its site breadcrumbs, I came accross the following requirement:

Add some text around the current page title (<title>) in a breadcrumb segment, with the route match based on regex (Paths to replace with custom breadcrumbs).

So practically speaking, we could have the following regex examples, for a News section:

regex!/news-example/([^/]*) :: News Example: <title>
regex!/news-example/([^/]*) :: News Example Index | /news-example :: News Example: <title>
regex!/news-example/([^/]*) :: <title>, in section News Example
regex!/news-example/([^/]*) :: News Example Index | /news-example :: <title>, in section News Example

I tried testing various combinations of options configured on module's admin settings page (/admin/config/user-interface/easy-breadcrumb), but unfortunately, I couldn't figure out how this could be achieved, without additional custom code.

The closest I could get was with the following regex:

regex!/news-example/([^/]*) :: <title>

and then added a bit of PHP logic in MYTHEME_preprocess_breadcrumb to add the necessary text in front of the page title, which felt like somewhat defeating the purpose of using the module for this particular use case.

Since the module already provides solutions to override texts in breadcrumb segments and replace the current page title with an internal token/tag (<title>), perhaps it could combine both and allow segments with text **and** the tag.
For example: "Some text: <title>, some more text | /some/path"

If I missed, overlooked or misunderstood anything in module's current settings, and this could already be achieved with the current features, I would greatly appreciate some pointers, guidance and maybe configuration examples of how some text could be added around a title component (<title>), for "Paths to replace with custom breadcrumbs".

In any case, we would greatly appreciate to have your feedback on this feature request, in particular, whether you would have any recommendations or suggestions on how this potential requirement could be achieved in general, for a custom breadcrumb.

Feel free to let us know if you have any questions, comments, objections, advice, or would need more information on this feature request, we would surely be glad to help!
Thanks in advance !

✨ Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France dydave

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024