Design adjustments, new content and more
This commit is contained in:
26
site/controllers/notes.php
Executable file
26
site/controllers/notes.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?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) {
|
||||
|
||||
$tag = urldecode(param('tag'));
|
||||
$notes = collection('notes');
|
||||
|
||||
if (empty($tag) === false) {
|
||||
$notes = $notes->filterBy('tags', $tag, ',');
|
||||
}
|
||||
|
||||
return [
|
||||
'tag' => $tag,
|
||||
'notes' => $notes->paginate(6)
|
||||
];
|
||||
|
||||
};
|
Reference in New Issue
Block a user