Topic: Search blog's post content
use this snippet if you want search blog's post by content or title
<form method="post" class="form-horizontal col-md-12" action=""> <div class="form-group"> <div class="input-group"> <input type="text" name="name" class="form-control" placeholder="search by title ..."> <span class="input-group-btn"> <button class="btn btn-default btn-link" type="submit" name="submit"><i class="fa fa-search"></i></button> </span> </div> </div> </form> <?php $pages = Page::children('blog'); ?> <?php $name = strtolower($_POST['name']); if(isset($_POST['submit'])) { $counter = 0; echo '<p>results for <b>' .$_POST['name']. '</b> :</p>'; echo '<ul class="list-unstyled">'; foreach($pages as $page) { $content = strtolower(Pages::content($page['slug'])); $title = strtolower($page['title']); if (strpos($title , $name) !== false OR strpos($content , $name) !== false) { echo '<li>'; echo '<a href="blog/'.$page['slug'].'">' .$page['title']. '</a>'; echo '</li>'; $counter++; } } echo '</ul>'; if ($counter === 0) { echo '<p><i>no matches found</i></p>'; } else { echo '<p>found ' .$counter. '</p>'; } } ?>