File tree 3 files changed +38
-1
lines changed
3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 218
218
219
219
'layout ' => env ('STATAMIC_LAYOUT ' , 'layout ' ),
220
220
221
+ /*
222
+ |--------------------------------------------------------------------------
223
+ | Blueprint Template Base Path
224
+ |--------------------------------------------------------------------------
225
+ |
226
+ | When using @blueprint in a collection's template setting, Statamic looks for
227
+ | templates in /resources/views/{collection}/{blueprint}.antlers.html. Set this
228
+ | value to use a different base path
229
+ | (e.g. 'templates' for /resources/views/templates/).
230
+ |
231
+ */
232
+
233
+ 'blueprint_template_base_path ' => env ('STATAMIC_BLUEPRINT_TEMPLATE_PATH ' , null ),
234
+
221
235
];
Original file line number Diff line number Diff line change @@ -528,7 +528,10 @@ public function template($template = null)
528
528
529
529
protected function inferTemplateFromBlueprint ()
530
530
{
531
- $ template = $ this ->collection ()->handle ().'. ' .$ this ->blueprint ();
531
+ $ basePath = config ('statamic.system.blueprint_template_base_path ' );
532
+ $ prefix = $ basePath ?: $ this ->collection ()->handle ();
533
+
534
+ $ template = $ prefix .'. ' .$ this ->blueprint ();
532
535
533
536
$ slugifiedTemplate = str_replace ('_ ' , '- ' , $ template );
534
537
Original file line number Diff line number Diff line change @@ -1915,6 +1915,26 @@ public function it_gets_and_sets_an_inferred_template_from_blueprint()
1915
1915
$ this ->assertEquals ('articles.custom ' , $ entry ->template ());
1916
1916
}
1917
1917
1918
+ #[Test]
1919
+ public function it_respects_custom_blueprint_template_base_path ()
1920
+ {
1921
+ // Set custom base path for test
1922
+ config (['statamic.system.blueprint_template_base_path ' => 'custom.path ' ]);
1923
+
1924
+ $ collection = tap (Collection::make ('articles ' )->template ('@blueprint ' ))->save ();
1925
+ $ blueprint = tap (Blueprint::make ('standard_article ' )->setNamespace ('collections.articles ' ))->save ();
1926
+ $ entry = Entry::make ('test ' )->collection ($ collection )->blueprint ($ blueprint ->handle ());
1927
+
1928
+ // entry uses the custom path instead of collection handle
1929
+ $ this ->assertEquals ('custom.path.standard_article ' , $ entry ->template ());
1930
+
1931
+ // entry uses slugified custom path when that template exists
1932
+ View::shouldReceive ('exists ' )->with ('custom.path.standard-article ' )->andReturn (true );
1933
+ $ this ->assertEquals ('custom.path.standard-article ' , $ entry ->template ());
1934
+
1935
+ config (['statamic.system.blueprint_template_base_path ' => null ]);
1936
+ }
1937
+
1918
1938
#[Test]
1919
1939
public function it_gets_and_sets_the_layout ()
1920
1940
{
You can’t perform that action at this time.
0 commit comments