how to search a particular profilemanger field???

what i required is ??

for example i have metadata called collegename .......

i create a input box for search ..... in tat i dont know how to write a sql query  %like % in the elgg_get_entities..

i check all the documentation but i am not getting any solution ....

can u suggest ur solutions . so tat i can develope.....

http://reference.elgg.org/entities_8php.html#af085c8362e49c4f52d4f1fcf58ca6fb8

but dont know how to write it exactly and display it .....

 

 

  • i dont know how to use joins ........ can you  give an example for that also .............

  • I removed the duplicated comments from this thread.

  • thnks -@juho jaakkola ..... can you tell the solution for that

     

  • You can use the function below:

    function specific_get_metadata($name , $val){
    if(!empty($name) 
              && !empty($val)){
                      $pval['metadata_name'] = $name;
                      $pval['metadata_value'] = $val; 
          return elgg_list_entities_from_metadata($sval);
    }
    return false;
    }

    echo specific_get_metadata('collegename', 'college name');

  • liang lee .. if i use this my page gets blocked .... nothing displayed

     

  • can i share this using github can u tell me the solution

     

  • $query = 'sample';

    $use = elgg_get_entities_from_metadata(array(
        'type' => 'user',
        'metadata_names' => 'collegename',
        'limit' => '10',
         'metadata_name_value_pairs' => array('name' => 'collegename', 'value' => '%'.$query.'%', 'operand' => 'LIKE'),



        
    ));
      foreach ($use as $user) {
        $fiels = $user->collegename;
        $fiels1 = $user->state;
        $fiels2 = $user->city;
    echo $fiels,$fiels1,$fiels2;

    }

  • using this i am getting the values ..........

  • function specific_get_metadata($name , $val){
    if(!empty($name)
    && !empty($val)){
    $pval['metadata_name'] = $name;
    $pval['metadata_value'] = $val;
    return elgg_list_entities_from_metadata($pval);
    }
    return false;
    }

    echo specific_get_metadata('collegename', 'college name');

    Yes there is mistake! i fixed

  • @Liang: Does the normal elgg_getter function really make any sense here? It will only return entities that match the metadata value "exactly".

    @sathishkumar: I would suggest to study the code of the bundled search plugin. Especially, the file search_hooks.php should be interesting for you because it contains the functions used to retrieve the results based on certain types of queries (object entities/content, groups and users). I don't think there's much documentation on it available. You might want to take a look especially at the search_users_hook() function because it returns users if the data in their profile field matches the query. But the search does only include the default profile fields.

    If you don't want a separate search box for your specific search it might even be quite simple to add your additional metadata to be searched on to the default profile fields. Line 135 of search_hooks.php:

    $profile_fields = array_keys(elgg_get_config('profile_fields'));

    retrieves the profile fields metadata names that will be included in the search. The array $profile_fields will contain the names then. If you add as next line:

    $profile_fields[] = 'collegename';

    this metadata field will be searched on additionally.

    The README.txt included in the search plugin folder explains a few details of customizing the Elgg search. But it won't explain much about searching on metadata because this is normally not done with the exception of the profile field data. The doc is also only about including additonal types of objects to be searched on with the normal Elgg search box. If you want to implement a separate search page, you would implement your own search query code. But you can take the code in search_hooks.php as starting point and most likely the code will get simpler if you want to provide a more specific search compared to the default Elgg search.