sterzycom/site/controllers/notes.php

37 lines
847 B
PHP

<?php
return function($site, $pages, $page) {
// fetch the basic set of pages
$articles = $page->children()->listed()->flip();
// 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...
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).'... </p><p> <a href="' . $url . '">Read More &rarr;</a></p>';
}
return $string;
}
?>