CB exact name search
version: 1.2.1 (so I don't know about how this works out in the latest version, someone confirm please)
file: administrator/components/com_comprofiler/plugin.class.php
line: 2354
return $condition;
change to
//dirty hack to make search for exact name possible
if(strpos($condition, 'u.`username') && strpos($condition, 'OR')){
//there is a search for username and there are more then one
if(JRequest::getVar('exact_name_search', '')){
//exact name search is desired
//get the name field as posted
$search_username = JRequest::getVar('username', '');
$search_username = strip_tags($search_username);
$condition = "(u.`username` LIKE '%".$search_username."%')";
}
}
return $condition;
then to add a checkbox next to the name-search-field I used JQuery because CB templating is ... well ... tricky to say the least.
So in my template file I load the javascript when on the CB userlist page like this:
if($option=='com_comprofiler' && JRequest::getVar('task', '')=='usersList'){
echo '<script type="text/javascript" src="/templates/templatename/javascript/add_exact_search_checkbox.js"></script>';
}
this is the JQuery code to add the checkbox next to the searchfield:
var exact_name_search_jQuery = jQuery.noConflict();
exact_name_search_jQuery(document).ready(function() {
//add checkbox and label
exact_name_search = ' <label><input type="checkbox" name="exact_name_search" value="1" /> make exact search on name</label>';
exact_name_search_jQuery("#username").after(exact_name_search);
});
make sure JQuery is already loaded when using this.