Guy Verville Posted December 1, 2013 Share Posted December 1, 2013 http://creacc.espaceproduction.com/ This is a site in its infancy. The code for the search engine is the original one with one exception: i have renamed search.php to recherche.php So the form in the head is: <form id='search_form' action='<?php echo $config->urls->root?>rechercher/' method='get'> <input type='text' name='q' id='search_query' value='<?php echo htmlentities($input->whitelist('q'), ENT_QUOTES, 'UTF-8'); ?>' /> <button type='submit' id='search_submit'>Rechercher</button> </form> and the code in the recherche.php is: <?php $out = ''; if($q = $sanitizer->selectorValue($input->get->q)) { $input->whitelist('q', $q); $matches = $pages->find("title|body|corps~=$q, limit=50"); $count = count($matches); if($count) { if ($count==1){$s='';}else{$s='s';} $out .= '<h2>Résultat : $count page'.$s.'</h2><ul class="nav">'; foreach($matches as $m) { $out .= "<li><p><a href='{$m->url}'>{$m->title}</a><br />{$m->summary}</p></li>"; } $out .= '</ul>'; } else { $out .= '<h2>Recherche infructueuse</h2>'; } } else { $out .= '<h2>Que cherchez-vous ?</h2>'; } include("./elements/entete.inc"); echo $out; include("./elements/pied.inc"); Search, for example, Montréal. Nothing is passed, nothing happens. Link to comment Share on other sites More sharing options...
Roope Posted December 1, 2013 Share Posted December 1, 2013 (edited) I think that it has something to do with (page name) language support. Now your search form points to http://creacc.espaceproduction.com/rechercher/ but because of lang support page actually lives in lang prefixed url http://creacc.espaceproduction.com/fr/rechercher/. Now PW does redirect and thus loses the search query. You could try something like this: <form id='search_form' action='<?php echo $pages->get("/rechercher/")->url; ?>' method='get'> <input type='text' name='q' id='search_query' value='<?php echo htmlentities($input->whitelist('q'), ENT_QUOTES, 'UTF-8'); ?>' /> <button type='submit' id='search_submit'>Rechercher</button> </form> Edited December 1, 2013 by Roope 2 Link to comment Share on other sites More sharing options...
Guy Verville Posted December 1, 2013 Author Share Posted December 1, 2013 Thank you very much! That was it, except that the code should read $pages->get("/rechercher")->url; Link to comment Share on other sites More sharing options...
Roope Posted December 1, 2013 Share Posted December 1, 2013 Yep, sorry.. Path selector always begins with slash. I'll fix my example. You could also use page id or any other valid selector. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now