Entity id token stops working when enabling Token display in ECK entity

Created on 22 July 2020, over 4 years ago

If we enable Token display mode in ECK entity, id token stops working. So in Pathauto pattern like my-eck-entity/[my_eck_entity:id]-page all path becomes without id, equal to my-eck-entity/-page.

Source of this problem seems is missing `ID` field in display settings. Can we add `ID` field to display?

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇦🇲Armenia murz Yerevan, Armenia

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇦Ukraine dunot
    function mymodule_token_info() {
         $eck_type['element'] = [
            'name' => t("eck"),
            'description' => t("Tokens related to eck"),
            'needs-data' => 'machine_name_of_your_eck',
        ];
        ..
        $eck['id'] = [ // add this token п.ч. пропадает
           'name' => t("eck id"),
           'description' => t("Id of eck"),
        ];
    
         return [
           'types' => [
             ..
              'element' => $eck_type
          ],
          'tokens' => [
             ..
             'element' => $eck
          ],
      ];
    }
    function .._tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
      $replacements = [];
      if ($type == 'machine_name_of_your_eck' && !empty($data['machine_name_of_your_eck'])) {
        $eck = $data['element'];
        $eck_id = $eck->id();
         foreach ($tokens as $name => $original) {
          switch ($name) {
            case 'id':
                $replacements[$original] = $eck_id;
              break;
              ..
          }
        }
        return $replacements;
    }
    
  • Status changed to Closed: works as designed 4 months ago
  • 🇧🇪Belgium dieterholvoet Brussels

    Source of this problem seems is missing `ID` field in display settings. Can we add `ID` field to display?

    Not sure what the problem is here, but id fields aren't usually available in view displays. I'm going to close this issue since it's very old, but feel free to reopen if someone is still experiencing this.

Production build 0.71.5 2024