1 <?php
defined('IN_CMS') or die('No direct access allowed.');
4 Theme functions for search
6 function has_search_results() {
7 if($items = IoC
::resolve('search')) {
8 return $items->length() > 0;
14 function total_search_results() {
15 if($total = IoC
::resolve('total_search')) {
22 function search_results() {
23 $posts = IoC
::resolve('search');
25 if($result = $posts->valid()) {
26 // register single post
27 IoC
::instance('article', $posts->current(), true);
36 function search_term() {
37 return (Request
::uri_segment(1) == 'search' ? Request
::uri_segment(2) : '');
40 function search_next($text = 'Next', $default = '') {
41 $per_page = Config
::get('metadata.posts_per_page');
42 $offset = Input
::get('offset', 0);
43 $total = IoC
::resolve('total_search');
45 $pages = floor($total / $per_page);
46 $page = $offset / $per_page;
49 return '<a href="' . current_url() . '?offset=' . ($offset +
$per_page) . '">' . $text . '</a>';
55 function search_prev($text = 'Previous', $default = '') {
56 $per_page = Config
::get('metadata.posts_per_page');
57 $offset = Input
::get('offset', 0);
58 $total = IoC
::resolve('total_search');
60 $pages = ceil($total / $per_page);
61 $page = $offset / $per_page;
64 return '<a href="' . current_url() . '?offset=' . ($offset - $per_page) . '">' . $text . '</a>';