statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.05k stars 530 forks source link

No output if taxonomy referenced in a taxonomy terms fieldtype has the same spelling as the fieldtype handle. #5827

Closed Pixney-William closed 2 years ago

Pixney-William commented 2 years ago

Bug description

Using the same slug for a taxonomy terms fieldtype as the handle for the taxonomy prevents you from then listing your taxonomies in the view.

This worked earlier but was introduces in one of the last versions.

It is the same issue no matter if i use the regex or runtime parser

How to reproduce

Create taxonomy

image image

Use the taxonomy terms fieldtype on your page and make sure you name this field discipline and then add some tags.

image
      -
        handle: discipline
        field:
          mode: default
          create: true
          taxonomies:
            - discipline
          display: Discipline
          type: terms
          icon: taxonomy
          listable: false
          instructions_position: above
          read_only: false

Add code to your view to list them

{{ discipline }}
    {{ title }}
{{ /discipline }}

As you will notice, there are no titles displaying. The issue as it seems is in the naming. When the field handle is the same as the taxonomy used in the fieldtype.

If you simply change the handle in the snippet above to discipline_alt_name and do

{{ discipline_alt_name }}
    {{ title }}
{{ /discipline_alt_name }}

It works as intended

Logs

No response

Versions

Statamic 3.3.6 Pro Laravel 8.83.8 PHP 8.0.12 doublethreedigital/duplicator 2.1.1 jonassiewertsen/statamic-livewire 2.9.0 transformstudios/review 3.2.1

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

regex (default)

Additional details

No response

jasonvarga commented 2 years ago

Have you associated the taxonomy with the collection?

Go configure the collection in the control panel and choose the discipline taxonomy.

Pixney-William commented 2 years ago

Thanks @jasonvarga , that did the trick. Ill close!