Finish to setup data access
This commit is contained in:
parent
90c998fa41
commit
80f72e7dc9
10 changed files with 73 additions and 36 deletions
9
public/site/controllers/site.php
Normal file
9
public/site/controllers/site.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
return function ($page) {
|
||||
$data = $page->toArray();
|
||||
$data['template'] = (string) $page->template();
|
||||
return [
|
||||
'genericData' => $data,
|
||||
];
|
||||
};
|
||||
|
|
@ -1,8 +1,3 @@
|
|||
<script>
|
||||
const kirbyData = {
|
||||
pageUri: '<?= $page->uri() ?>',
|
||||
pageTemplate: '<?= $page->template() ?>',
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
3
public/site/snippets/generic-template.php
Normal file
3
public/site/snippets/generic-template.php
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<?php snippet('header') ?>
|
||||
<div id="app"></div>
|
||||
<?php snippet('footer') ?>
|
||||
|
|
@ -1 +1 @@
|
|||
<h1><?= $page->title() ?></h1>
|
||||
<h1><?= $page->title() ?></h1>
|
||||
7
public/site/templates/home.json.php
Normal file
7
public/site/templates/home.json.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
$specificData = [];
|
||||
|
||||
$data = array_merge($genericData, $specificData);
|
||||
|
||||
echo json_encode($data);
|
||||
|
|
@ -1,3 +1 @@
|
|||
<?php snippet('header') ?>
|
||||
<div id="app"></div>
|
||||
<?php snippet('footer') ?>
|
||||
<?php snippet('generic-template') ?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue