/** * Tries to find content that matches the input query * @param string $query */ public function find($query) { $q = implode('%', explode(' ', $query)); $sql = 'SELECT content.* FROM content JOIN idiom ON content.idiom_id = idiom.id WHERE idiom.code = ? AND content.publish = 1 AND ( content.keywords like (?) OR content.alias like (?) OR content.title like (?) OR content.description like (?) OR content.intro like (?) OR content.html like (?) ) ORDER BY visits DESC'; // Prepare values and run query $q = "%{$q}%"; $rows = R::getAll($sql, array(BootWiki::getIdiom(), $q, $q, $q, $q, $q, $q)); $results = R::convertToBeans('content', $rows); if (!empty($results)) { foreach ($results as $item) { $content = new Content($item->alias); $content->importBean($item); $this->items[] = $content; } } }
<div class="col-md-12"> <?php echo $this->html; ?> </div><!--/span--> </div><!--/row--> <?php } ?> </div> </div> </div> </div> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="web/js/bootstrap.min.js"></script> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <script src="web/js/ie10-viewport-bug-workaround.js"></script> <!-- Include google analytics if exists --> <?php if (file_exists(TEMPLATEPATH . '/' . BootWiki::getIdiom() . '/ga.php')) { include TEMPLATEPATH . '/' . BootWiki::getIdiom() . '/ga.php'; } ?> </body> </html>
/** * This loads all content items */ public function loadAll() { // Load featured $sql = ' SELECT content.* FROM content LEFT JOIN idiom ON content.idiom_id = idiom.id WHERE idiom.code = ? AND content.featured = 1 AND content.publish = 1'; $rows = R::getAll($sql, array(BootWiki::getIdiom())); $beans = R::convertToBeans('content', $rows); $featured = array(); foreach ($beans as $item) { $content = new Content(); $content->importBean($item); $featured[] = $content; } $this->featured = $featured; }