Hello
i can use Token for "Paths to replace with custom breadcrumbs"

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

maxasus123 created an issue. See original summary.

korzh-nick’s picture

diff --git a/src/EasyBreadcrumbBuilder.php b/src/EasyBreadcrumbBuilder.php
index 35a401f..aa58b4f 100755
--- a/src/EasyBreadcrumbBuilder.php
+++ b/src/EasyBreadcrumbBuilder.php

 /**
  * Primary implementation for the Easy Breadcrumb builder.
@@ -622,6 +623,9 @@ class EasyBreadcrumbBuilder implements BreadcrumbBuilderInterface {
       return NULL;
     }

+    $token_service = \Drupal::token();
+    $title = $token_service->replace($title);
+
     return $title;
   }
greg boggs’s picture

greg boggs’s picture

Version: 8.x-1.x-dev » 2.x-dev
Component: User interface » Code
Status: Active » Needs work

This one probably also needs a dependency added on token

almador’s picture

Hi!

Big thanks for the module!

I've checked 2.0.3 and 2.x-dev and it seems that tokens are not supported yet?

I was hoping to use the tokens in "Titles to be replaced while generating segments" setting.

greg boggs’s picture

Merge requests encouraged :)

almador’s picture

I've tried with #2 solution, but didn't get it to work.

1. Added to public function getTitleString (in file EasyBreadcrumbBuilder.php)

    $token_service = \Drupal::token();
    $title = $token_service->replace($title);

2. Added in file easy_breadcrumb.info.yml

dependencies:
  - token:token

3. At admin/config/user-interface/easy-breadcrumb
in section Titles to be replaced while generating segments
provided replacement pattern: {{ field_category_in_english }}::{{ field_category }}

Fields are from my view.

4. In easy_breadcrumb.services.yml

services:
  easy_breadcrumb.breadcrumb:
    class: Drupal\easy_breadcrumb\EasyBreadcrumbBuilder
    arguments:

added: '@token',

5. drush cr

greg boggs’s picture

Can you open a merge request?

greg boggs’s picture

looks like a merge error.

ankitjhakal’s picture

Assigned: Unassigned » ankitjhakal
ankitjhakal’s picture

Assigned: ankitjhakal » Unassigned

bbu23 made their first commit to this issue’s fork.

bbu23’s picture

Hi, sorry, I'm in a bit of a hurry now, but this seems like a good place for adding tokens to fields. I know that the original issue needs tokens for "Paths to replace with custom breadcrumbs", but I need for "Home" and do not have time right now to do it for that as well. But I do want to push my changes here as a starting point, there are multiple things that should be done, and maybe this issue could be converted to something like "Tokens everywhere" or at least where possible.

My commit is not final, requieres dependency injection and module dependency. Will come back to it later if maintainers/the community are interested in using tokens in fields.

spuky’s picture

to keep everybody updated there is an issue in Dynamic breadcrumb to merge into EB which should bring token support to EB so maybe we should focus on one solution...

spuky’s picture

@bbu23 thanks for bringing up your MR once #3467372: Merge Dynamic breadcrumb is ready we will have a dependency on Token... and can work on making tokens work in more places...

bbu23’s picture

@spuky sure! I needed it for the update.
Cool, that will be great!

maxasus123 changed the visibility of the branch 3088784-can-use-token to hidden.

spuky changed the visibility of the branch 3088784-can-use-token to active.

spuky changed the visibility of the branch 3088784-can-use-token to active.