filterByAttribute using more than one attribute

Permalink 1 user found helpful
hi everyone

i'm trying to make a member search page, which is going pretty well although i can't find how to filter by more than one attribute (as an 'OR').

eg if searching for 'tom'
i would like to check both the first_name and last_name attributes that i created..

i guess the sort of thing i envisage is:

$this->filterByAttributes(array('first_name', 'last_name'), '%'.$name.'%', 'like');


where 2 attributes are passed instead of just one (so they are both checked)..

the reason behind all this is i don't want a separate textbox for first_name and last_name, just a single 'name' field..

any help is greatly appreciated !

 
ecoit replied on at Permalink Reply
i have a solution that works pretty well so i thought i'd post it here for the next person ..

the solution was to edit the first_name and last_name attributes and select 'Content included in "Keyword Search".'

and then i overrode the members.php controller and exploded the $keywords array, and filteredByKeyword for each one .. like this:

$arr_keywords = explode(" ", $keywords);
foreach($arr_keywords as $keyword) {
  if ($keyword != '') {
   $userList->filterByKeywords($keyword);
  }
}


seems to work perfectly !