Single blueprint with multiple templates

Wanted outcome:

I’d like to have a single Blueprint (easier to manage) with multiple page themes. And to be able to ‘Change template’ for any page.

What currently works:

Right now everything is working as I have each theme with their relevant blueprint. So I’m able to change themes with no issues.

The Blueprints all work with what I have tried with below, but not the themes switching.

What I’ve tried:

When I try removing the current [page].yml contents and replacing it with…

title: Photos

extends: layouts/default

pages: true

…it doesn’t work.

I’ve also tried to adding the following to above and also the default.yml file…

options:
  changeTemplate:
    - default
    - articles
    - posts
    - photos
    - videos
    - newsletter
    - quotes
    - testimonials
    - tools
    - search
    - export
    - fullpage

I’ve even removed all [page].yml files and created a plugin…

  Kirby::plugin('kia/singleblueprint', [
    'blueprints' => [
      'pages/photos' => __DIR__ . '/default.yml',
      'pages/posts' => __DIR__ . '/default.yml'
    ]
  ]);

The Blueprints do work with all of the methods above, but I never get access to the ‘Change template’ option with any of the methods.

Notes

Kirby 4.6.1
Localhost

What am I missing:

I’m not sure if there’s something I’ve overlooked. Any help in the right direction would be grand!

Thanks in advance!

NOTE:

The forum wasn’t giving my an option to add a tag for the ‘Questions’ category for some reason. So feel free to move this post. if needed. Thanks.

Hm, I don’t really understand what you are trying to do. What is a “theme” in your understanding, a template in Kirby speak?

Sorry, I mean ‘Template’ not theme.

(Changed the title of the post)

The blueprint assigned to a page determines its content filename, and the content filename in turn determines the template that is used to render the page.

So if you want to have a different layout for pages that use same blueprint, instead of using multiple templates, you could use different snippets to display the content. You could then use a “theme switcher” select field inside the page blueprint to decide inside the template which snippet to use.

Understood.

I already use snippets for some items. However, what I’d like to do is make what I’d like to accomplish more efficient.

As I explained, everything works just fine other than being able to use the ‘Change template’ drop down menu –– it’s greyed out.

So I’m wondering if it’s a feature, a bug or me missing a setting/option in the .yml file for the reason I can’t change templates.

If we have the option to have a default layout using extends: layouts/default or by crating a specific plug in, then it should be possible to change the template?

No?

Could you post the complete blueprint with those settings?

Sure, but I’m not 100% sure what to post, but here goes…

Notice that default.yml and posts.yml are exactly the same, this will allow my to change template.

But when I try to use the extends: layouts/default feature with photo.yml and the /layout/default.yml even though it works fine, I’m unable to change template.

Hope that makes sense.


Here’s the full /layout/default.yml

title: Default

options:
  changeTemplates:
    - default
    - articles
    - posts
    - photos
    - videos
    - newsletter
    - quotes
    - testimonials
    - tools
    - search
    - export
    - fullpage

tabs:
  Post:
    columns:
      main:
        width: 2/4
        sections:
          main:
            type: fields
            fields:
              video_platform:
                type: select
                label: Use video platform.........
                options:
                  bunny: Bunny
                  youtube: YouTube
                  x: X
                  odysee: Odysee
                  dailymotion: Dailymotion
                  rumble: Rumble
              odysee:
                  label: Odysee
                  type: url                  
              dailymotion:
                  label: Dailymotion
                  type: url
              rumble:
                label: Rumble
                type: url                  
              video:
                label: Bunny video ID
                type: text
              youtube:
                label: YouTube
                type: url
              x:
                label: X
                type: url
              post_header:
                label: Header
                type: text
              post_subheader:
                label: Subheader
                type: textarea
                size: small
              pre_post:
                label: Pre post
                type: textarea
                size: small
              post:
                label: The post
                type: textarea
                size: large                 
      sidebar:
        width: 1/4
        sections:
          sidebar:
            type: fields
            fields:
              images_files:
                label: Images & files
                type: files
                sortable: true
                layout: cards
                image: 
                  cover: true
                  ratio: 1/1
              show_image:
                label: Image in post
                type: checkboxes
                options:
                  Yes: no
              tags:
                label: Tags
                type: tags
                max: 3
                options:
                  type: query
                  query: site.index.pluck("tags", ",", true)
              date:
                label: date
                display: MMM D YYYY
                default: now
                required: true
              time:
                label: Time
                type: time
                default: now
                step:
                  unit: minute
                  size: 1
                required: true
             
      sidebarr:
        width: 1/4
        sections:
          sidebarr:  
            type: fields
            fields:
              image_meta:
                label: Meta thumbnail
                type: files
                max: 1
                layout: cards
                image: 
                  cover: true
                  ratio: 1/1
              title_meta:
                label: Meta title
                type: text
              description_meta:
                label: Meta description
                type: textarea
                size: small
                buttons: false
              featured_post:
                type: toggle
                label: Featured post
                text:
                  - 'No'
                  - 'Yes'
              subscriber_only:
                type: toggle
                label: Subscriber only post
                text:
                  - 'No'
                  - 'Yes'
              landing_page:
                type: toggle
                label: Landing page
                text:
                  - 'No'
                  - 'Yes'
              hide_items:
                label: Hide...
                type: checkboxes
                options:
                  Logo: no
                  Navigation: no
                  Posts: no 
  Notes:            
    width: 4/4
    sections:
      notes:
        type: fields
        fields:
          note:
            type: textarea
            size: large

Here’s the full photo.yml

title: Photos

extends: layouts/default

options:
  changeTemplate:
    - default
    - articles
    - posts
    - photos
    - videos
    - newsletter
    - quotes
    - testimonials
    - tools
    - search
    - export
    - fullpage

Here’s the full posts.yml

title: Post

options:
  changeTemplate:
    - default
    - articles
    - posts
    - photos
    - videos
    - newsletter
    - quotes
    - testimonials
    - tools
    - search

create:
  fields:
    - tags

tabs:
  Post:
    columns:
      main:
        width: 2/4
        sections:
          main:
            type: fields
            fields:
              video_platform:
                type: select
                label: Use video platform...
                options:
                  bunny: Bunny
                  youtube: YouTube
                  x: X
                  odysee: Odysee
                  dailymotion: Dailymotion
                  rumble: Rumble
              odysee:
                  label: Odysee
                  type: url                  
              dailymotion:
                  label: Dailymotion
                  type: url
              rumble:
                label: Rumble
                type: url                  
              video:
                label: Bunny video ID
                type: text
              youtube:
                label: YouTube
                type: url
              x:
                label: X
                type: url
              post_header:
                label: Header
                type: text
              post_subheader:
                label: Subheader
                type: textarea
                size: small
              post:
                label: The post
                type: textarea
                size: large                
      sidebar:
        width: 1/4
        sections:
          sidebar:
            type: fields
            fields:
              images_files:
                label: Images & files
                type: files
                sortable: true
                layout: cards
                image: 
                  cover: true
                  ratio: 1/1
              show_image:
                label: Image in post
                type: checkboxes
                options:
                  Yes: no
              tags:
                label: Tags
                type: tags
                max: 3
                options:
                  type: query
                  query: site.index.pluck("tags", ",", true)
              date:
                label: date
                display: MMM D YYYY
                default: now
                required: true
              time:
                label: Time
                type: time
                default: now
                step:
                  unit: minute
                  size: 1
                required: true
             
      sidebarr:
        width: 1/4
        sections:
          sidebarr:  
            type: fields
            fields:
              image_meta:
                label: Meta thumbnail
                type: files
                max: 1
                layout: cards
                image: 
                  cover: true
                  ratio: 1/1
              title_meta:
                label: Meta title
                type: text
              description_meta:
                label: Meta description
                type: textarea
                size: small
                buttons: false
              featured_post:
                type: toggle
                label: Featured post
                text:
                  - 'No'
                  - 'Yes'
              subscriber_only:
                type: toggle
                label: Subscriber only post
                text:
                  - 'No'
                  - 'Yes'
              landing_page:
                type: toggle
                label: Landing page
                text:
                  - 'No'
                  - 'Yes'
              hide_items:
                label: Hide...
                type: checkboxes
                options:
                  Logo: no
                  Navigation: no
                  Posts: no 
  Notes:            
    width: 4/4
    sections:
      notes:
        type: fields
        fields:
          note:
            type: textarea
            size: large            

Here’s the full default.yml

title: Post

options:
  changeTemplate:
    - default
    - articles
    - posts
    - photos
    - videos
    - newsletter
    - quotes
    - testimonials
    - tools
    - search

create:
  fields:
    - tags

tabs:
  Post:
    columns:
      main:
        width: 2/4
        sections:
          main:
            type: fields
            fields:
              video_platform:
                type: select
                label: Use video platform...
                options:
                  bunny: Bunny
                  youtube: YouTube
                  x: X
                  odysee: Odysee
                  dailymotion: Dailymotion
                  rumble: Rumble
              odysee:
                  label: Odysee
                  type: url                  
              dailymotion:
                  label: Dailymotion
                  type: url
              rumble:
                label: Rumble
                type: url                  
              video:
                label: Bunny video ID
                type: text
              youtube:
                label: YouTube
                type: url
              x:
                label: X
                type: url
              post_header:
                label: Header
                type: text
              post_subheader:
                label: Subheader
                type: textarea
                size: small
              post:
                label: The post
                type: textarea
                size: large                
      sidebar:
        width: 1/4
        sections:
          sidebar:
            type: fields
            fields:
              images_files:
                label: Images & files
                type: files
                sortable: true
                layout: cards
                image: 
                  cover: true
                  ratio: 1/1
              show_image:
                label: Image in post
                type: checkboxes
                options:
                  Yes: no
              tags:
                label: Tags
                type: tags
                max: 3
                options:
                  type: query
                  query: site.index.pluck("tags", ",", true)
              date:
                label: date
                display: MMM D YYYY
                default: now
                required: true
              time:
                label: Time
                type: time
                default: now
                step:
                  unit: minute
                  size: 1
                required: true
             
      sidebarr:
        width: 1/4
        sections:
          sidebarr:  
            type: fields
            fields:
              image_meta:
                label: Meta thumbnail
                type: files
                max: 1
                layout: cards
                image: 
                  cover: true
                  ratio: 1/1
              title_meta:
                label: Meta title
                type: text
              description_meta:
                label: Meta description
                type: textarea
                size: small
                buttons: false
              featured_post:
                type: toggle
                label: Featured post
                text:
                  - 'No'
                  - 'Yes'
              subscriber_only:
                type: toggle
                label: Subscriber only post
                text:
                  - 'No'
                  - 'Yes'
              landing_page:
                type: toggle
                label: Landing page
                text:
                  - 'No'
                  - 'Yes'
              hide_items:
                label: Hide...
                type: checkboxes
                options:
                  Logo: no
                  Navigation: no
                  Posts: no 
  Notes:            
    width: 4/4
    sections:
      notes:
        type: fields
        fields:
          note:
            type: textarea
            size: large            

The option is called changeTemplate(singular), not changeTemplates. Seems to be correct in all but layouts/default.yml. Bit confusing also that you use the same title post` for both default.yml and posts.yml

Apart from that, changing templates works for me with those blueprints.

Oh man, it’s always the simplest thing!

Thanks [yet] again @texnixe!!

All fixed.