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: [Djulia] View Search Logs

By Dave - August 27, 2009

Hi Djulia,

I've been thinking about this more and I think it might be better to add on the page that does the searching.

How many search pages do you have (just one?)

And what information do you want recorded to the database? (fields searched, keyword used, matches returned?)
Dave Edis - Senior Developer
interactivetools.com

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