Topic: search blog post's titles
simple snippet for searching blog's posts via title
<form method="post" class="form-horizontal col-md-12" actiom=""> <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) { $title = strtolower($page['title']); if (strpos($title , $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>'; } } ?>