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 !

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

DYdave created an issue. See original summary.

dydave’s picture

Quick follow-up on this ticket :

Please find attached to this comment a patch on the 2.x branch :
3392845-3-easy_breadcrumb-regex-allow-title-tag-replacement-in-segment-text.patch

Which is an attempt to provide replacements of the <title> tag in the text segments for configured regex under Paths to replace with custom breadcrumbs.
The added code checks whether the string is present in the text segment and then replaces it once the value of the title has been resolved.

This change should be harmless enough and shoudn't have any impact on any of module's current settings.
It should allow adding text around the <title> in the regex configuration breacrumb replacement segments, instead of strictly only replacing the <title> tag.

Since module's maintainers are now requesting changes to be submitted in merge requests, this patch is also available in issue's merge request opened above at #2.

Lastly, I've related the issue with a few other tickets that I found in current issue queue with similar requests or changes around the same pieces of code.

We would greatly appreciate if you could please try testing the patch, in particular, with various configured parameters, such as titles with HTML Markup, translations, Paths to be excluded while generating segments, Titles to be replaced while generating segments and any other options on module's admin settings form.
Could you please review the changes suggested in the patch and give us your feedback ?

Feel free to let us know if you have any questions, comments, suggestions objections or concerns on any aspects of this feature request or this initial patch, we would definitely be very happy to hear your feedback.
Thanks in advance !

dydave’s picture

admirlju’s picture

Status: Needs review » Reviewed & tested by the community

I've done some testing, both with what was asked in #3 and some other options. From my tests, this works perfectly, and it's a really useful feature. I think this can be merged. RTBC.

Greg Boggs made their first commit to this issue’s fork.

greg boggs’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

  • Greg Boggs committed 9a954c6e on 2.x authored by DYdave
    Issue #3392845 by DYdave, admirlju: Regex: Allow <title> tag to be...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.