AndyB
Well-known member
I extended XenForo_ControllerPublic_Search.
How do I get the $input['keywords'] variable?
My code:
Thank you.
How do I get the $input['keywords'] variable?
My code:
PHP:
<?php
class Andy_SearchLog_ControllerPublic_Search extends XFCP_Andy_SearchLog_ControllerPublic_Search
{
public function actionSearch()
{
// call parent function
parent::actionSearch();
// declare variable
$searchLogFile = '';
$searchWords = '';
// get options from Admin CP -> Options -> Convert Image -> Search Log File
$searchLogFile = XenForo_Application::get('options')->searchLogFile;
if ($searchLogFile != '')
{
// verify log file exists
if (file_exists($searchLogFile))
{
// adjust for local timezone
$dateline = time() + XenForo_Locale::getTimeZoneOffset();
// format date
$formatedDate = date("m/d/y h:ia", $dateline);
// search word
$searchWords = $input['keywords'];
// prepare data
$data = $formatedDate . ' / Search Words: ' . $searchWords . '
';
// update log file
$handle = fopen($searchLogFile, 'a');
fwrite($handle, $data);
fclose($handle);
}
}
// return parent
return parent::actionSearch();
}
}
?>
Thank you.