Skip to content

Filtering by Language and Tags #546

@husenunicorn

Description

@husenunicorn

this is my config.yml

i18n:
  structure: multiple_files
  locales: [id, en]
  default_locale: id
  initial_locales: default
  omit_default_locale_from_filename: true

collections:
  - name: posts
  - folder: content/posts
  - path: "{{slug}}/index"
  - media_folder: ""
  - public_folder: ""
  - i18n: true

I want to filter languages in my collection entries using view_filters. I tried asking Claude AI and got a configuration like this:

view_filters:
  - label: "Indonesian"
    field: i18n.locale
    pattern: "id"
  - label: "English"
    field: i18n.locale
    pattern: "en"

However, this does not work. The CMS shows no errors, but when I try applying the filter, the result is always zero entries.

When I try filtering tags with a configuration like this:

fields:
- label: "Tag & Author"
        name: "taxonomies"
        widget: "object"
        collapsed: false
        summary: "Tag & Author"
        i18n: true
        fields:
          - lable: "Tag"
            name: "tag"
            widget: "select"
            multiple: true
            min: 1
            max: 3
            dropdown_threshold: 3
            required: true
            hint: "Min 1 & Max 3"
            options: ["A", "B", "C"]
            i18n: duplicate
          - lable: "Author"
            name: "author"
            widget: "select"
            multiple: true
            min: 1
            dropdown_threshold: 1
            required: true
            options: ["A", "B"]
            i18n: duplicate

view_filters:
    - label: Tag A
      field: taxonomies.tag
      pattern: A
    - label: Tag B
      field: taxonomies.tag
      pattern: B

Sveltia also shows no errors, but the result is the same as filtering language zero entries.

I also tried filtering Featured article and Drop cap fields, and those work correctly. The configuration looks like this:

fields:
   - label: "Featured & Enable drop caps on posts"
      name: "extra"
      widget: "object"
      collapsed: false
      summary: "Featured & Enable drop caps on posts"
      i18n: true
      fields:
         - label: "Featured"
            name: "featured"
            widget: "boolean"
            i18n: true
         - label: "Enable drop caps on posts"
            name: "enable_drop_caps_on_posts"
            widget: "boolean"
            i18n: true

view_filters:
    - label: Featured posts
      field: extra.featured
      pattern: true
    - label: posts drop cap
      field: extra.enable_drop_caps_on_posts
      pattern: true

Is it possible to filter languages and tags in my use case? Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions