How to search in XFields

Frequently Asked Questions (read only)

How to search in XFields

Postby FI-DD » Thu Jul 20, 2006 4:34 pm

With this little hack you can search in XFields, too.



1. Open search.php and find this:

Code: Select all
<tr>

  <td colspan="2"><input type="submit" value=" Search ">




add above:

Code: Select all
<tr><td></td><td><input id="chk_xfield" type="checkbox" name="search_in_xfield" value="yes" <?=($_GET['search_in_xfield'] ? 'checked' : '');?>> <label for="chk_xfield">Search in XFields</label></td>

</tr>




2. Find this:

Code: Select all
global $search, $sql;




change to this:

Code: Select all
global $search, $sql, $search_in_xfield;




3. Find this:

Code: Select all
if ($select){




add above:

Code: Select all
  if($search_in_xfield == "yes"){

      $file = file('../data/xfields-data.txt');//Change the path if necessary

      foreach($file as $line){

         $line_arr = explode("|>|", $line);

         $all_values = explode("||", $line_arr[1]);

         foreach($all_values as $single_value){

            $single = explode("|", $single_value);

            if(@preg_match("/$search/i", $single[1])){

               $select[] = $line_arr[0];

            }

         }

      }

   }
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Return to FAQ



Who is online

Users browsing this forum: No registered users and 1 guest