add default game to tnm

main
Ugo Finnendahl 2 months ago
parent 9efe183658
commit 453bcb0d6f
  1. 10
      site/blueprints/pages/templates.yml
  2. 16
      site/blueprints/pages/tournament.yml
  3. 2
      site/blueprints/pages/xoi.yml
  4. 14
      site/controllers/home.php

@ -0,0 +1,10 @@
title: Templates
create:
status: listed
sections:
pages:
type: pages
label: Games
template: xoi

@ -17,6 +17,12 @@ sections:
width: 1/2
label: Date
type: date
default:
width: 1/1
label: Template
type: pages
max: 1
query: site.find("Templates").drafts
# layout:
# type: layout
# layouts:
@ -24,10 +30,18 @@ sections:
# fieldsets:
# - heading
# - simple_game
pages:
type: pages
label: Games
template: xoi
text: "[{{ page.startdate.toDate('d.m.') }}] {{ page.players.toPages.first.forename }} {{ page.players.toPages.first.surname }} vs. {{ page.players.toPages.nth(1).forename }} {{ page.players.toPages.nth(1).surname }}"
sortBy: startdate desc
status: unlisted
# pages2:
# type: pages
# label: Default
# template: xoi
# sortBy: startdate desc
# status: draft
# max: 1
# limit: 1

@ -1,7 +1,7 @@
title: Game
create:
status: listed
status: draft
sections:
fields:

@ -18,12 +18,25 @@ return function ($page, $site, $kirby) {
try {
$kirby->impersonate('kirby');
if ($site->find($tournament)->default()->toPage()){
$json["error"] = $site->find($tournament)->default()->toPage()->out();
$id = $site->find($tournament)->default()->toPage()->copy(
[
'slug' => Str::slug($name),
'parent' => $site->find($tournament),
'children' => false, // copy children
'files' => false, // don't copy files
'isDraft' => false,
]
);
} else {
$id = $site->find($tournament)->createChild([
'content' => $content,
'slug' => Str::slug($name),
'template' => 'xoi',
'isDraft' => false
]);
}
$json["status"] = "ok";
$json["url"] = $id->url();
} catch (\Exception $e) {
@ -38,3 +51,4 @@ return function ($page, $site, $kirby) {
'error' => $error
];
};

Loading…
Cancel
Save