22
33use Kirby \Cms \Page ;
44use Kirby \Cms \Pages ;
5+ use Kirby \Cms \Site ;
56use Kirby \Content \VersionId ;
67use Kirby \Template \Template ;
78
89class ModulePage extends Page
910{
10- public function parentUrl (): string
11- {
12- return $ this ->parents ()->count () ? $ this ->parents ()->first ()->url () : $ this ->site ()->url ();
13- }
1411 public function render (
1512 array $ data = [],
1613 $ contentType = 'html ' ,
1714 VersionId |string |null $ versionId = null
1815 ): string {
19- go ($ this ->parent ()->url () . '# ' . $ this ->slug ());
16+
17+ $ parentUrl = $ this ->page ()->url ();
18+ if ($ token = get ('_token ' )) {
19+ $ parentUrl .= '?_token= ' . $ token ;
20+ }
21+
22+ go ($ parentUrl . '# ' . $ this ->slug ());
2023 }
2124 public function renderModule (array $ params = [])
2225 {
@@ -29,11 +32,19 @@ public function renderModule(array $params = [])
2932 ...$ params
3033 ]));
3134 }
32- public function moduleName ()
35+ public function page (): Page |Site
36+ {
37+ return $ this ->parent ()->parent () ?? $ this ->site ();
38+ }
39+ public function parentUrl (): string
40+ {
41+ return $ this ->page ()->url ();
42+ }
43+ public function moduleName (): string
3344 {
3445 return $ this ->blueprint ()->title ();
3546 }
36- public function moduleId ()
47+ public function moduleId (): string
3748 {
3849 return str_replace ('. ' , '-- ' , $ this ->intendedTemplate ());
3950 }
@@ -42,7 +53,7 @@ public function parents(): Pages
4253 $ parents = parent ::parents ();
4354 return $ parents ->filter ('slug ' , '!= ' , 'modules ' );
4455 }
45- public function metaDefaults ()
56+ public function metaDefaults (): array
4657 {
4758 return ['robotsIndex ' => false ];
4859 }
0 commit comments