Maybe I'm missing something obvious here but I am struggling to figure out how to print out the current page title when using the "Paths to replace with custom breadcrumbs" option.

I'm using regex to adjust the breadcrumb for an Event node to make it link back to a main Views listing of event. That portion works fine like this:

regex!/events/([^/]*)/ :: Calendar | /calendar which prints out Home > Calendar (with the word Calendar linked to /calendar)

However, what I would like to do is to provide a non-linked, text only version of the current node page in the breadcrumb. If I don't use the custom breadcrumb option, it prints that fine as Home > My Event.
But what I am looking for is how to print the current page title while still using the custom breadcrumbs option, so I end up with Home > Calendar > My Event instead

I've tried $title and {{ title }} but feel like I am missing something obvious here. Hopefully this makes sense, if something is unclear please let me know and thanks in advance for any help!

CommentFileSizeAuthor
#2 easy_breadcrumb-use_page_title.patch5.01 KBgeoffreyr

Comments

hotsaucedesign created an issue. See original summary.

geoffreyr’s picture

StatusFileSize
new5.01 KB

Hi, here's a rough first pass to use the <title> delimiter to use the current page title.

geoffreyr’s picture

Status: Active » Needs review
tlwatson’s picture

#2 works - for dev, not the stable 8.x-1.13 version mentioned in this issue.

I think it would be really slick if you could use Tokens in the "paths to replace" field... then you could achieve this with [current-page:title]. Tokens would open up a bunch of other possibilities as well.

greg boggs’s picture

Version: 8.x-1.13 » 8.x-1.x-dev

Thanks for the review Trisha.

Token support would certainly be powerful.

The current replace functionality bypasses the breadcrumb creation code entirely to replace the crumbs with your custom value.

selinav’s picture

Will this function be added on the next version 8.1.14 ?
The patch doesn't work on 8.1.13, how to do on this version?
I need it because, I have a lot of content and it will be great it is work instead of doing it manually.

Mfgr45’s picture

Working perfectly on 8.x-1.x-dev thanks ! Hope it will be on the next release.

@selinav you can temporarily install the dev version if you really need this feature with :
composer require drupal/easy_breadcrumb:1.x-dev@dev

selinav’s picture

Thank you, I don't see the pattern to use. I have not the token explorer on the 1.x-dev version.

n8tron’s picture

After using this patch, I got

Warning: in_array() expects parameter 2 to be array, string given in Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->normalizeText() (line 914 of modules/contrib/easy_breadcrumb/src/EasyBreadcrumbBuilder.php).

This seems to fix it.

diff --git a/src/EasyBreadcrumbBuilder.php b/src/EasyBreadcrumbBuilder.php
index e571df8..3d79607 100644
--- a/src/EasyBreadcrumbBuilder.php
+++ b/src/EasyBreadcrumbBuilder.php
@@ -898,7 +898,7 @@ class EasyBreadcrumbBuilder implements BreadcrumbBuilderInterface {
       for ($i = 1; $i < $words_quantity; ++$i) {
 
         // Transforms this word only if it is not in the list of ignored words.
-        if (!in_array($words[$i], $ignored_words, TRUE)) {
+        if (is_array($ignored_words) && !in_array($words[$i], $ignored_words, TRUE)) {
           $words[$i] = Unicode::ucfirst($words[$i]);
         }
       }

Anybody else have this issue?

brooke_heaton’s picture

I agree that use of tokens would be ideal. I'm not sure if that falls into the scope of this issue, but think it should be persued.

jane_irwin’s picture

maenjuel’s picture

Useful feature, I was looking for the same functionality as well. Applying the patch from #3167058-2: Page title in "custom breadcrumbs" to 8.x-1.15 worked for me.

Regarding tokens: that would definitely make this module quite powerful. This feature was proposed in #3088784: Can use Token for "Paths to replace with custom breadcrumbs" as well.

greg boggs’s picture

Awesome. Did you get the warning from #9 too or did you include the code from #9?

maenjuel’s picture

There was no error, no. Simply worked, without applying the code from #9 :)

greg boggs’s picture

Status: Needs review » Reviewed & tested by the community

greg boggs’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

shriaas’s picture

Guess I am missing something but seems like <title> is not getting replaced with actual page title, here is the cutsom breadrcumb pattern regex!/my_video/(\d*) :: Explore Videos | /node/41 :: <title>
The Explore Videos part is working properly but <title> is not. I have enabled the Use the real page title when available, if I remove this pattern I am able to see Page title getting displayed in the breadcrumb, but the <title> in pattern is not working. What am I missing? Also there is no example of using <title> in the documentation, it would be really helpful if docs included example of using it with normal patterns and regex.

carolpettirossi’s picture

Hi @Shriaas,

I was facing the same issue as you. It seems that 2.0.2 introduced a bug. However, it has been fixed here: https://www.drupal.org/project/easy_breadcrumb/issues/3262378