@@ -48,26 +48,37 @@ public function findImagesWithoutContentOrTemplate(): array
4848 ];
4949 }
5050 }
51-
5251 return $ images ;
5352 }
5453
5554 public function availableFileTemplates (): array
5655 {
5756 $ templates = [];
5857 $ filesPath = kirby ()->root ('blueprints ' ) . '/files ' ;
58+ $ blueprintFiles = Dir::index ($ filesPath , true );
59+
60+ // debug: log all found blueprint file paths
61+ // foreach ($blueprintFiles as $path) {
62+ // $this->log('debug', 'Found blueprint: ' . $path);
63+ // }
5964
60- foreach (glob ($ filesPath . '/*.yml ' ) as $ file ) {
61- $ name = pathinfo ($ file , PATHINFO_FILENAME );
65+ foreach ($ blueprintFiles as $ relativePath ) {
66+ if (pathinfo ($ relativePath , PATHINFO_EXTENSION ) !== 'yml ' ) {
67+ continue ;
68+ }
69+ $ name = pathinfo ($ relativePath , PATHINFO_FILENAME );
6270
63- // skip the 'default' template
71+ // skip 'default.yml' regardless of folder depth
6472 if ($ name === 'default ' ) {
6573 continue ;
6674 }
6775
68- $ label = ucfirst (str_replace (['- ' , '_ ' ], ' ' , $ name ));
76+ $ parts = explode ('/ ' , $ relativePath );
77+ $ label = implode (' / ' , array_map (fn ($ part ) => ucfirst (str_replace (['- ' , '_ ' ], ' ' , pathinfo ($ part , PATHINFO_FILENAME ))), $ parts ));
78+ $ value = str_replace ('.yml ' , '' , $ relativePath );
79+
6980 $ templates [] = [
70- 'value ' => $ name ,
81+ 'value ' => $ value ,
7182 'text ' => $ label
7283 ];
7384 }
@@ -76,19 +87,18 @@ public function availableFileTemplates(): array
7687 return $ templates ;
7788 }
7889
79- // --------------------------------------------------------------------------
80- // logging
81- // implements custom logging to /site/logs/debug.log
82- public function log (string $ level , string $ message ): void
83- {
84- $ timestamp = date ('Y-m-d H:i:s ' );
85- $ logDir = kirby ()->root ('logs ' );
86- $ logFile = $ logDir . '/debug.log ' ;
87-
88- // ensure log directory exists
89- Dir::make ($ logDir );
90- $ entry = Str::unhtml ("[ $ timestamp][ $ level] $ message " ) . PHP_EOL ;
91- F::append ($ logFile , $ entry );
92- }
93-
90+ // --------------------------------------------------------------------------
91+ // logging
92+ // implements custom logging to /site/logs/debug.log
93+ public function log (string $ level , string $ message ): void
94+ {
95+ $ timestamp = date ('Y-m-d H:i:s ' );
96+ $ logDir = kirby ()->root ('logs ' );
97+ $ logFile = $ logDir . '/template-checker.log ' ;
98+
99+ // ensure log directory exists
100+ Dir::make ($ logDir );
101+ $ entry = Str::unhtml ("[ $ timestamp][ $ level] $ message " ) . PHP_EOL ;
102+ F::append ($ logFile , $ entry );
103+ }
94104}
0 commit comments