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!
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | easy_breadcrumb-use_page_title.patch | 5.01 KB | geoffreyr |
Comments
Comment #2
geoffreyr commentedHi, here's a rough first pass to use the
<title>delimiter to use the current page title.Comment #3
geoffreyr commentedComment #4
tlwatson#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.
Comment #5
greg boggsThanks 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.
Comment #6
selinav commentedWill 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.
Comment #7
Mfgr45 commentedWorking 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
Comment #8
selinav commentedThank you, I don't see the pattern to use. I have not the token explorer on the 1.x-dev version.
Comment #9
n8tronAfter 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.
Anybody else have this issue?
Comment #10
brooke_heaton commentedI 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.
Comment #11
jane_irwinComment #12
maenjuelUseful 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.
Comment #13
greg boggsAwesome. Did you get the warning from #9 too or did you include the code from #9?
Comment #14
maenjuelThere was no error, no. Simply worked, without applying the code from #9 :)
Comment #15
greg boggsComment #17
greg boggsComment #19
shriaasGuess I am missing something but seems like
<title>is not getting replaced with actual page title, here is the cutsom breadrcumb patternregex!/my_video/(\d*) :: Explore Videos | /node/41 :: <title>The Explore Videos part is working properly but
<title>is not. I have enabled theUse 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.Comment #20
carolpettirossi commentedHi @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
Comment #21
carolpettirossi commented