cms icon indicating copy to clipboard operation
cms copied to clipboard

[5.x] Add configurable @blueprint template base path

Open o1y opened this issue 9 months ago • 4 comments

Adds a new configuration option to customize where Statamic looks for templates when using @blueprint in collections to map templates to entry blueprints.

If template: @blueprint is set on the collection, by default it looks for a template that corresponds with the blueprint in resources/views/{collection}/{template}.antlers.html.

  • [x] With the new config option the user can set a different base path /resources/views/{blueprint_template_base_path}/{template}.antlers.html.

o1y avatar Mar 28 '25 10:03 o1y

What's your actual use case for this?

jasonvarga avatar Apr 25 '25 18:04 jasonvarga

I want to reuse the same set of templates (mapped to blueprints with the same name) across multiple collections without duplicating template files. This is my views folder:


resources/
└── views/
    ├── shared_blueprints/ 
    │   ├── page_builder.antlers.html
    │   ├── simple_page.antlers.html
    │   └── article.antlers.html
    └── ... 

Currently, ⁠template: @blueprint forces templates into collection-specific folders (⁠views/pages/, ⁠views/landing_pages/). This would require duplication. With the proposed config option, you could avoid this template dispatcher partial:

{{ partial src="shared_blueprints/{{ blueprint }}" }}

o1y avatar Apr 25 '25 20:04 o1y

Gotcha so you just want to avoid the collection prefix and replace it with your own basically.

jasonvarga avatar Apr 25 '25 21:04 jasonvarga