Skip to content

Instantly share code, notes, and snippets.

@bugsysop
Created September 26, 2016 05:05
Show Gist options
  • Select an option

  • Save bugsysop/0cf6dd57ddc58bc84449d6056ac26285 to your computer and use it in GitHub Desktop.

Select an option

Save bugsysop/0cf6dd57ddc58bc84449d6056ac26285 to your computer and use it in GitHub Desktop.
<!--
site/templates/search.php
Source : https://forum.getkirby.com/t/search-templates/5323/12
-->
<?php snippet('header') ?>
<div class="text">
<?php if($results): ?>
<?php foreach($results as $result): ?>
<div class="text">
<h1><a href="<?php echo $result->url() ?>">
<?php
$breadcrumb = '';
foreach($result->parents()->flip() as $parent) {
echo $parent->title()->html(). ' » ';
}?>
<?php echo $result->title() ?></a></h1>
<p>
<?php echo $result->description() ?> <?php echo excerpt($result->text(), 300) ?> [...] <a href="<?php echo $result->url() ?>">Read more.</a>
</p>
</div>
<?php endforeach ?>
<div>
<?php snippet('pagination', array('pagination' => $results->pagination())) ?>
</div>
<?php elseif($search->query()): ?>
<div>
<h3>No posts found matching «<?php echo html($search->query()) ?>».</h3>
<p>Your search for <strong><?php echo html($search->query()) ?></strong> returned no results.</p>
</div>
<?php endif ?>
<h3>Tags</h3>
<p>
<?php foreach($tags as $tag): ?>
<a href="<?php echo $tag->url() ?>">#<?php echo $tag->name() ?></a>
<?php endforeach ?>
</p>
</div>
<?php snippet('footer') ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment