Created
January 2, 2012 16:22
-
-
Save bastianallgeier/1551286 to your computer and use it in GitHub Desktop.
Search Template for Kirby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- site/snippets/pagination.php --> | |
<nav role="pagination"> | |
<div class="count"> | |
<strong><?php echo $pagination->countItems() ?></strong> Results / showing <strong><?php echo $pagination->numStart() ?></strong> - <strong><?php echo $pagination->numEnd() ?></strong> | |
</div> | |
<div class="buttons"> | |
<? if($pagination->hasPrevPage()): ?> | |
<a class="prev" href="<?= $pagination->prevPageURL() ?>">‹ previous</a> | |
<? else: ?> | |
<span class="prev">‹ previous</span> | |
<? endif ?> | |
<? if($pagination->hasNextPage()): ?> | |
<a class="next" href="<?= $pagination->nextPageURL() ?>">next ›</a> | |
<? else: ?> | |
<span class="next">next ›</span> | |
<? endif ?> | |
</div> | |
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- site/templates/search.php --> | |
<?php snippet('header') ?> | |
<?php snippet('menu') ?> | |
<?php | |
$search = new search(array( | |
'searchfield' => 'q', | |
'ignore' => array('search', 'error'), | |
'words' => true, | |
'paginate' => 10 | |
)); | |
$results = $search->results(); | |
?> | |
<h1><?php echo html($page->title()) ?></h1> | |
<form action="<?php echo thisURL() ?>"> | |
<input type="text" placeholder="Type in your searchword…" name="q" value="<?php echo html($search->query()) ?>" /> | |
<input type="submit" value="Search" /> | |
</form> | |
<?php if($results): ?> | |
<?php snippet('pagination', array('pagination' => $results->pagination())) ?> | |
<ul> | |
<?php foreach($results as $row): ?> | |
<li> | |
<strong><a href="<?php echo $row->url() ?>"><?php echo html($row->title()) ?></a></strong> | |
<a href="<?php echo $row->url() ?>"><?php echo html($row->url()) ?></a> | |
</li> | |
<?php endforeach ?> | |
</ul> | |
<?php snippet('pagination', array('pagination' => $results->pagination())) ?> | |
<?php elseif($search->query()): ?> | |
<div class="no-results">No results for <strong><?php echo html($search->query()) ?></strong></div> | |
<?php endif ?> | |
<?php snippet('footer') ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment