sterzycom/site/controllers/notes.php

37 lines
847 B
PHP
Raw Permalink Normal View History

2015-11-29 20:38:31 +01:00
<?php
return function($site, $pages, $page) {
// fetch the basic set of pages
2020-02-25 15:56:59 +01:00
$articles = $page->children()->listed()->flip();
2015-11-29 20:38:31 +01:00
// add the tag filter
if($tag = param('tag')) {
$articles = $articles->filterBy('tags', $tag, ',');
}
// fetch all tags
$tags = $articles->pluck('tags', ',', true);
// apply pagination
$articles = $articles->paginate(7);
$pagination = $articles->pagination();
return compact('articles', 'tags', 'tag', 'pagination');
};
function split_words($string, $url) {
if (strlen($string) > 1000) {
// truncate string
$stringCut = substr($string, 0, 1000);
// make sure it ends in a word so assassinate doesn't become ass...
2017-08-17 12:32:06 +02:00
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).'... </p><p> <a href="' . $url . '">Read More &rarr;</a></p>';
2015-11-29 20:38:31 +01:00
}
return $string;
}
?>