Initial commit
This commit is contained in:
19
site/controllers/album.php
Normal file
19
site/controllers/album.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Controllers allow you to separate the logic of your templates from your markup.
|
||||
* This is especially useful for complex logic, but also in general to keep your templates clean.
|
||||
*
|
||||
* In this example, we define the `$gallery` variable which is passed to the template
|
||||
*
|
||||
* More about controllers:
|
||||
* https://getkirby.com/docs/guide/templates/controllers
|
||||
*/
|
||||
return function ($page) {
|
||||
|
||||
$gallery = $page->images()->sortBy('sort', 'filename');
|
||||
|
||||
return [
|
||||
'gallery' => $gallery
|
||||
];
|
||||
|
||||
};
|
||||
15
site/controllers/note.php
Normal file
15
site/controllers/note.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Controllers allow you to separate the logic of your templates from your markup.
|
||||
* This is especially useful for complex logic, but also in general to keep your templates clean.
|
||||
*
|
||||
* In this example, we split the tags from the tags field to create a nice tag list
|
||||
*
|
||||
* More about controllers:
|
||||
* https://getkirby.com/docs/guide/templates/controllers
|
||||
*/
|
||||
return function ($page) {
|
||||
return [
|
||||
'tags' => $page->tags()->split(','),
|
||||
];
|
||||
};
|
||||
32
site/controllers/notes.php
Normal file
32
site/controllers/notes.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Controllers allow you to separate the logic of your templates from your markup.
|
||||
* This is especially useful for complex logic, but also in general to keep your templates clean.
|
||||
*
|
||||
* In this example, we handle tag filtering and paginating notes in the controller,
|
||||
* before we pass the currently active tag and the notes to the template.
|
||||
*
|
||||
* More about controllers:
|
||||
* https://getkirby.com/docs/guide/templates/controllers
|
||||
*/
|
||||
return function ($page) {
|
||||
|
||||
/**
|
||||
* We use the collection helper to fetch the notes collection defined in `/site/collections/notes.php`
|
||||
*
|
||||
* More about collections:
|
||||
* https://getkirby.com/docs/guide/templates/collections
|
||||
*/
|
||||
$notes = collection('notes');
|
||||
|
||||
$tag = param('tag');
|
||||
if (empty($tag) === false) {
|
||||
$notes = $notes->filterBy('tags', $tag, ',');
|
||||
}
|
||||
|
||||
return [
|
||||
'tag' => $tag,
|
||||
'notes' => $notes->paginate(6)
|
||||
];
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user