/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<form id="xsearch_form" action="index.php" method="get"> <input type="hidden" name="article_id" value="REX_ARTICLE_ID" /> <input type="hidden" name="clang" value="REX_CLANG_ID" /> <input type="text" size="20" name="xsearch" value="<?php if(!empty($_GET['xsearch'])) echo htmlspecialchars($_GET['xsearch']); ?>" /> </form> <?php if(!empty($_REQUEST['xsearch'])) { $xsearch = new XSearch(); $showmax = 10; $xsearch->setLimit($start = isset($_GET['start'])?intval($_GET['start']):0, $showmax); if(count($result = $xsearch->search($_REQUEST['xsearch']))) { echo '<div class="searchresults">'; $ids = array(); foreach($result['hits'] as $hit) { if(!in_array($hit['fid'], $ids)) { $article = OOArticle::getArticleById($hit['fid']); if($hit['type'] == 'db_column' AND $hit['table'] == $REX['TABLE_PREFIX'].'article') $text = $hit['article_teaser']; else $text = $hit['highlightedtext']; $ids[] = $hit['fid']; echo '<div class="result"> </div>'; } if(count($ids) >= 10) break; } echo '</div>'; // Pagination if($result['count'] > $showmax) { $self = OOArticle::getArticleById(REX_ARTICLE_ID); echo '<p class="pagination">'; for($i = 0; ($i*$showmax) <= $result['count']; $i++) { if(($i*$showmax) == $start) echo '<span class="selected">'.($i+1).'</span>'; else } echo '</p>'; } } } ?>