Jump to content

Search does not work


Guy Verville
 Share

Recommended Posts

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

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 by Roope
  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...