View Search Logs

By Djulia - August 26, 2009

Hi,

It would be interesting to record in a table the keywords used by the visitors with the Custom Search Forms.

A plugin is possible ?

I tried to use the code suggested by Dave in the file addForm.php, but that does not seem to be possible with the function search.

Thanks, Djulia

Re: [Djulia] View Search Logs

By Dave - August 26, 2009

Hi Djulia,

Yes it's possible. We may need to add a plugin hook for it but we can do that.

The first step would be to identify which urls to log. We could add a plugin hook to _createDefaultWhereWithFormInput() in the viewer_functions.php file that passed back an array of fieldnames being search and keywords. Would that work?

You might not want to log everything, though, for example num = 1.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] View Search Logs

By Djulia - August 26, 2009

Hi Dave,

>> We could add a plugin hook to _createDefaultWhereWithFormInput() in the viewer_functions.php file that passed back an array of fieldnames being search and keywords.

Yes, that would be well !

The idea is to obtain a tool of decision and to direct the contents so necessary (...)

You think of being able to create the plugin ?

Thanks, Djulia

Re: [Dave] View Search Logs

By Djulia - August 28, 2009 - edited: August 28, 2009

Hi Dave,

I have a search form for each section (sale house, sale appartment, rentals appartment...).
But, the form is identical for each section :
-----------------------------------------------------------
<form name="" method="" action="">
<label>Keyword : </label>
<input type="text" name="zip_code,sector,title,content" />

<label>City : </label>
<input type="text" name="city_keyword,zip_code,sector_keyword" />

<label>Price :</label>
<select name="prix_min">
<option value="0">30.000</option>
<option value="100000">100.000</option>
<option value="200000">200.000</option>
...
</select>
</form>
-----------------------------------------------------------

I would like to obtain the key word used for the fields Keyword and/or City.
It would be well, in the ideal, to obtain the price, but it is less important and that must complicate the plugin ?

The idea to obtain the matches returned is also very interesting.

It would be a good tool of statistics !

Thanks for the feedback, Djulia

Re: [Djulia] View Search Logs

By Dave - August 28, 2009

Hi Djulia,

I think the simplest solution for this case might be to custom code something for your specific page rather than have a generic plugin.

What about something like this:

$keywordFieldnames = array();
$keywordFieldnames[] = 'zip_code,sector,title,content';
$keywordFieldnames[] = 'city_keyword,zip_code,sector_keyword';
$keywordFieldnames[] = 'prix_min';

foreach ($keywordFieldnames as $fieldname) {
$keyword = @$_REQUEST[$fieldname];
if (!$keyword) { continue; }

// add code here to insert $keyword into database
// ...
}


Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] View Search Logs

By Djulia - August 29, 2009 - edited: August 29, 2009

Hi Dave,

Thanks ! That is for me the best approach.

That is very flexible and adapts very easily to the various needs.

Thank you very much !

Djulia