Same blueprint, same template, different page content

I am trying to create a blueprint for the products of a shop I’m building. Each product uses the the template but has a unique snippet to pull unique data from each product page.

Is there a way to create the blueprint to have a set of unique fields for each product. I can add all possible fields for each product to a blueprint, but I’d like the panel to only show the fields for the page that gets opened, i.e. fields for rods, or fields for reels, or fields for lures.

I had an idea but not sure it is possible. If there could be a select box that has each product listed and when you select a specific product, the fields related to that product show up.

Is any of this possible? Or is there a plugin that will do this?

I think this plugin might be helpful: https://github.com/medienbaecker/kirby-fieldtoggle

Thanks @texnixe, this looks like it is going to work great. I just need a little help before I waste hours. Below is how I am trying to modify the example but so far it’s not showing the rod options in the modal.

Hopefully @thguenther sees this thread and can give a few pointers.

products:
label:     Products
type:      structure
modalsize: large
fields:
  category:
    label: Category
    type:  fieldtoggle
    options:
      rods:         Rods
      reels:        Reels
      leaders:      Leaders
      tackle:       Tackle
      lures:        Lures
      weights:      Weights
      fishing_line: Fishing Line
      accessories:  Accessories
      videos:       Videos
    show:
      rods: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      reels:
      leaders:
      tackle:
      lures:
      weights:
      fishing_line:
      accessories:
      videos:
    hide:
      rods:
      reels: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      leaders: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      tackle: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      lures: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      weights: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      fishing_line: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      accessories: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      videos: rod_style rod_length rod_line_rating rod_lure_weight rod_price
    // Rods
    // =====================
    rod_style:
      label: Style
      type: text
    rod_length:
      label: Length
      type: text
    rod_line_rating:
      label: Line Rating
      type: text
    rod_lure_weight:
      label: Lure Weight
      type: text
    rod_price:
      label: Price
      type: number
      step: .01

I think the problem is your indentation. Check the example how all the different fields/labels etc. should be aligned. It should look like this:

fields:
  products:
    label:     Products
    type:      structure
    modalsize: large
    fields:
      category:
        label: Category
        type:  fieldtoggle
        options:
          rods:         Rods
          reels:        Reels
          leaders:      Leaders
          tackle:       Tackle
          lures:        Lures
          weights:      Weights
          fishing_line: Fishing Line
          accessories:  Accessories
          videos:       Videos
        show:
          rods: rod_style rod_length rod_line_rating rod_lure_weight rod_price
          reels:
          leaders:
          tackle:
          lures:
          weights:
          fishing_line:
          accessories:
          videos:
        hide:
          rods:
          reels: rod_style rod_length rod_line_rating rod_lure_weight rod_price
          leaders: rod_style rod_length rod_line_rating rod_lure_weight rod_price
          tackle: rod_style rod_length rod_line_rating rod_lure_weight rod_price
          lures: rod_style rod_length rod_line_rating rod_lure_weight rod_price
          weights: rod_style rod_length rod_line_rating rod_lure_weight rod_price
          fishing_line: rod_style rod_length rod_line_rating rod_lure_weight rod_price
          accessories: rod_style rod_length rod_line_rating rod_lure_weight rod_price
          videos: rod_style rod_length rod_line_rating rod_lure_weight rod_price
        // Rods
        // =====================
      rod_style:
        label: Style
        type: text
      rod_length:
        label: Length
        type: text
      rod_line_rating:
        label: Line Rating
        type: text
      rod_lure_weight:
        label: Lure Weight
        type: text
      rod_price:
        label: Price
        type: number
        step: .01

Why are you doing this in a structure field, do you want to have each product as an item in structure field instead of a single page? If so, why?

I was basing this off the example from the plugin. I’m still new to building blueprints so not sure about a lot still.

Without the structure field, your blueprint would/should/could look like this:

title: Product


fields:
  title:
    label: Title
    type:  text

  category:
    label: Category
    type:  fieldtoggle
    options:
      rods:         Rods
      reels:        Reels
      leaders:      Leaders
      tackle:       Tackle
      lures:        Lures
      weights:      Weights
      fishing_line: Fishing Line
      accessories:  Accessories
      videos:       Videos
    show:
      rods: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      reels:
      leaders:
      tackle:
      lures:
      weights:
      fishing_line:
      accessories:
      videos:
    hide:
      rods:
      reels: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      leaders: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      tackle: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      lures: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      weights: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      fishing_line: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      accessories: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      videos: rod_style rod_length rod_line_rating rod_lure_weight rod_price
    // Rods
    // =====================
  rod_style:
    label: Style
    type: text
  rod_length:
    label: Length
    type: text
  rod_line_rating:
    label: Line Rating
    type: text
  rod_lure_weight:
    label: Lure Weight
    type: text
  rod_price:
    label: Price
    type: number
    step: .01


Ok, I see where the difference is now.

Now a new question, is there a way to show/hide groups of fields instead of each individual field

No, but I just created a feature request (because I was asking myself that question): https://github.com/medienbaecker/kirby-fieldtoggle/issues/8

You can, however, use field groups to prevent cluttering your blueprints

title: Home

pages: false

fields:
  title:
    label: Title
    type:  text

  category:
    label: Category
    type:  fieldtoggle
    options:
      rods:         Rods
      reels:        Reels
      leaders:      Leaders
      tackle:       Tackle
      lures:        Lures
      weights:      Weights
      fishing_line: Fishing Line
      accessories:  Accessories
      videos:       Videos
    show:
      rods: rod
      reels:
      leaders:
      tackle:
      lures:
      weights:
      fishing_line:
      accessories:
      videos:
    hide:
      rods:
      reels: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      leaders: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      tackle: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      lures: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      weights: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      fishing_line: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      accessories: rod_style rod_length rod_line_rating rod_lure_weight rod_price
      videos: rod_style rod_length rod_line_rating rod_lure_weight rod_price
    // Rods
    // =====================
  rod:
    extends: rod

rod.yml

# /site/blueprints/fields/rod.yml
type: group
fields:
  rod_style:
    label: Style
    type: text
  rod_length:
    label: Length
    type: text
  rod_line_rating:
    label: Line Rating
    type: text
  rod_lure_weight:
    label: Lure Weight
    type: text
  rod_price:
    label: Price
    type: number
    step: .01

Thanks @texnixe, your’e the best. I was looking through the main plugin thread to see if there was an answer.

Hey @texnixe, I tried this solution but I get this error, The group field is missing?

It would help if I updated my version of Kirby :slight_smile:

I tried the setup you mentioned but it shows all the group fields in the panel. Here my blueprint:

# blueprint for each product in the shop
title: Product

# page settings
deletable: false
options:
  preview: false
# subpage settings
pages: false
# file settings
files: true

# individual panel fields
fields:
  title:
    label: Title
    type:  text
  text:
    label: Text
    type:  textarea
 # toggle fields for choosing product category and inputting their options
  category:
    label: Category
    type:  fieldtoggle
    options:
      rods:         Rods
      reels:        Reels
      leaders:      Leaders
      tackle:       Tackle
      lures:        Lures
      weights:      Weights
      fishing_line: Fishing Line
      accessories:  Accessories
      videos:       Videos
    show:
      rods:         rods
      reels:        reels
      leaders:      leaders
      tackle:       tackle
      lures:        lures
      weights:      weights
      fishing_line: fishing_line
      accessories:  accessories
      videos:       videos
    hide:
      rods: reels leaders tackle lures weights fishing_line accessories videos
      reels: rods leaders tackle lures weights fishing_line accessories videos
      leaders: rods reels tackle lures weights fishing_line accessories videos
      tackle: rods reels leaders lures weights fishing_line accessories videos
      lures: rods reels leaders tackle weights fishing_line accessories videos
      weights: rods reels leaders tackle lures fishing_line accessories videos
      fishing_line: rods reels leaders tackle lures weights accessories videos
      accessories: rods reels leaders tackle lures weights fishing_line videos
      videos: rods reels leaders tackle lures weights fishing_line accessories
# field groups
  rods:
    extends: rod
  reels:
    extends: reel
  leaders:
    extends: leader
  tackle:
    extends: tackle
  lures:
    extends: lure
  weights:
    extends: weight
  fishine_line:
    extends: fishing_line
  accessories:
    extends: accessory
  videos:
    extends: video

As I said - and that’s why I created the feature request issue mentioned above - you can’t use field groups in the hide/show options but would have to listt each individual field (so a lot of typing to do)

Sorry, was having my “homer simpson” moment, DOUUH

I still don’t see why you want to make your life complicated and don’t want to use different blueprints and templates. After all, all the user has to do is choose from a limited list of templates instead of selecting a category.

can you explain that a bit more, I’m still new to setting up blueprints

When users create a new page, they can select a particular template/blueprint. Now lets suppose you have a parent page “products”. In the blueprint for that page (`products.yml), you would define some templates the user is allowed to use for subpages:

title: Product Parent
pages:
  template:
    - rod
    - reel
    - lures

So instead of selecting a category and the getting a list of fields to fill in, the user would select the category via the blueprint. You would then have a blueprint rod.yml with the fields for rods, reel.yml with the fields for reels etc.

You can read up about blueprints in the docs: https://getkirby.com/docs/panel/blueprints

Ahh gotcha, just couldn’t picture how they would select the products. I was thinking earlier that there should be a way to select which products they needed to add by category rather than putting it all in one area.

Well, creating category subpages would be another option with a structure like this

products/
  -- reels/
    -- item 1
    -- item 2
  -- rods/
    -- item 1
    -- item 2
etc.