How to add custom fields to search query frontend

  • Helene Larocque
  • Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 2 months ago #77155 by Helene Larocque
How to add custom fields to search query frontend was created by Helene Larocque
Hi !
I noticed that the search field on the frontend member's list only search through "core fields" excluding custom fields. Is there a way we can include custom field in the search query?

Please Log in or Create an account to join the conversation.

More
8 years 2 months ago #77182 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic How to add custom fields to search query frontend
Hi Helene

Unfortunately, we could not search for data from extra custom fields you created.

Tuan

Please Log in or Create an account to join the conversation.

  • Helene Larocque
  • Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 2 months ago #77306 by Helene Larocque
Replied by Helene Larocque on topic How to add custom fields to search query frontend
Sad. I tried to use the "comment" field to put some useful information so the user may be found more easily but it doesn't seem to be part of the search query neither.
This has a important impact on the way people search for members because they do not always know the name but they may want to look for skills or else. Is it something that will be part of a next release ?

Please Log in or Create an account to join the conversation.

More
8 years 2 months ago #77307 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic How to add custom fields to search query frontend
It is easy to make the extension search for comment field. Please follow instructions below to get it works:

1. Open the file components/com_osmembership/model/members.php

2. Find this line of code
Code:
$config['search_fields'] = array('tbl.first_name', 'tbl.last_name', 'tbl.email', 'b.title');

3. Change it to
Code:
$config['search_fields'] = array('tbl.first_name', 'tbl.last_name', 'tbl.email', 'tbl.comment', 'b.title');

After that, the system should search for data in comment field, too

Tuan

Please Log in or Create an account to join the conversation.

  • Helene Larocque
  • Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 2 months ago #77309 by Helene Larocque
Replied by Helene Larocque on topic How to add custom fields to search query frontend
Great ! I will try that. I guess I could not update the component anymore after that, isn't it ?

Please Log in or Create an account to join the conversation.

More
8 years 2 months ago #77310 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic How to add custom fields to search query frontend
Just make a backup of that file and restore it after you update to new version !

Tuan

Please Log in or Create an account to join the conversation.

  • Helene Larocque
  • Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 2 months ago #77311 by Helene Larocque
Replied by Helene Larocque on topic How to add custom fields to search query frontend
OK. Thanks !

Please Log in or Create an account to join the conversation.