37 lines
841 B
PHP
37 lines
841 B
PHP
|
<?php
|
||
|
return function($site, $pages, $page) {
|
||
|
|
||
|
// fetch the basic set of pages
|
||
|
$articles = $page->children()->visible()->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, ' ')).'... <br> <a href="' . $url . '">Read More →</a>';
|
||
|
|
||
|
}
|
||
|
|
||
|
return $string;
|
||
|
}
|
||
|
?>
|