statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
31 stars 1 forks source link

Nav (not nav item) blueprint/data #690

Open edalzell opened 2 years ago

edalzell commented 2 years ago

Use Case:

Would be great to be able to attach this data to the nav via a blueprint.

Current workaround is to either make an assumption (leads to more fragile code), or making a top level item with some data, and therefore not used fields on the items.

Secondarily, need to be able to show/hide fields based on a Nav's type.

jackmcdade commented 2 years ago

This hurts my brain.

ELI8

edalzell commented 2 years ago

We have what we call a "super" menu:

CleanShot 2021-11-04 at 11 40 35@2x

Issue is that each of those menus needs to handled differently, for example one looks like this:

CleanShot 2021-11-04 at 11 42 05@2x

and another:

CleanShot 2021-11-04 at 11 42 27@2x

and yet another:

CleanShot 2021-11-04 at 11 42 46@2x

So each of these needs a type so we can pull in the correct partial. Not only that, some of those type have specific fields we want to show for the items (like an asset field on the ones w/ pictures), but NOT show on the other menu types.

So it would be loverly to be able to attach the blueprint to the nav itself and not the items, but have the item blueprint be aware of the nav type, so we can show/hide fields. Alternatively, if we could have multiple nav item blueprints, that would also work.

jackmcdade commented 2 years ago

ELI5

jackmcdade commented 2 years ago

Just kidding i get it now, thanks! <3

FrittenKeeZ commented 1 year ago

I need a lot more flexibility for navigations as well. I need to be able to disable external links for some navigations, and others I need customized blueprints for both internal and external links.

In this example I had to remove the built-in connection to collection and completely overtake the blueprint, as I was fighting against the CP handling

sections:
  main:
    display: Main
    fields:
      -
        handle: link_type
        field:
          type: radio
          display: Type
          options:
            intern: Intern
            extern: Extern
          inline: true
          validate:
            - required
      -
        handle: title
        field:
          type: text
          display: Title
          validate:
            - required
      -
        handle: intern
        field:
          type: entries
          display: Intern
          max_items: 1
          create: false
          collections:
            - hotels
          validate:
            - 'required_if:link_type,intern'
          if:
            link_type: intern
      -
        handle: url
        field:
          type: text
          display: Extern
          placeholder: 'https://varbergskusthotell.se/'
          validate:
            - 'required_if:link_type,extern'
            - sometimes
            - nullable
            - url
          if:
            link_type: extern
      -
        handle: region
        field:
          type: terms
          display: Region
          create: false
          max_items: 1
          mode: select
          taxonomies:
            - regions
          validate:
            - 'required_if:link_type,extern'
          if:
            link_type: extern
      -
        handle: city
        field: common.label
        config:
          display: City
          if:
            link_type: extern
      -
        handle: map
        field:
          type: assets
          display: Map
          allow_uploads: false
          container: main
          folder: /maps
          max_files: 1
          mode: grid
          restrict: true