I created a company_name text field on registration and I'd like to make the company names searchable as a selectlist (to make it easier for users to find available companies).
I've created a company_name_search searchlist but, of course, it is not working as the company names are stored in a different db table.
I'm trying to edit the administrator/components/com_jsn/helpers/fields/selectlist.php file but it is not working. You previously helped me with some edits for the text.php file so, based on that, I've come up with the code below (my new edits are currently commented out);
public static function getSearchQuery($field, &$query)
{
$option=JRequest::getVar($field->alias,null);
$db=JFactory::getDbo();
if($field->params->get('select_multiple',0))
{
foreach($option as $opt)
{
/*
if( $field->alias== 'company_name_search' )
{
$query->where('b.'.$db->quoteName( "company_name" ).' LIKE '.$db->quote('%"'.$opt.'"%'));
}
else
{
$query->where('b.'.$db->quoteName($field->alias).' LIKE '.$db->quote('%"'.$opt.'"%'));
}
*/
$query->where('b.'.$db->quoteName($field->alias).' LIKE '.$db->quote('%"'.$opt.'"%'));
}
}
else
{
/*
if( $field->alias== 'company_name_search' )
{
$query->where('b.'.$db->quoteName( "company_name" ).' = '.$db->quote($option));
}
else
{
$query->where('b.'.$db->quoteName($field->alias).' = '.$db->quote($option));
}
*/
$query->where('b.'.$db->quoteName($field->alias).' = '.$db->quote($option));
}
}
Am I making a mistake somewhere or is it not possible to achieve this?
Many thanks.