Advertisement:

Author Topic: How to implement User Search  (Read 57507 times)

itcafeonline

  • Full Member
  • ***
  • Posts: 245
How to implement User Search
« on: April 29, 2016, 03:19:03 am »
Can anyone point me towards how to approach implementing User Search? TIA

gaissa

  • Newbie
  • *
  • Posts: 13
Re: How to implement User Search
« Reply #1 on: April 29, 2016, 07:38:41 pm »
Can anyone point me towards how to approach implementing User Search? TIA

Check this topic: http://forums.osclass.org/general-help/important-how-to-have-a-really-funcional-search/msg139426/#msg139426
There is an user search and a few hacks to it. Just check it out :)

itcafeonline

  • Full Member
  • ***
  • Posts: 245
Re: How to implement User Search
« Reply #2 on: April 29, 2016, 09:35:26 pm »
That seems a unrelated thread. That is related ITEM search. I am looking for User Search

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: How to implement User Search
« Reply #3 on: April 29, 2016, 10:18:32 pm »
Hi,

What's exactly your idea? A search filter just like pattern or Category, so Pattern = Toyota and User = Username or xxxxxxx@domain.com => Search list with all ads posted by "Username or xxxxxxx@domain.com" contaning "Toyota"? ???

Regards

itcafeonline

  • Full Member
  • ***
  • Posts: 245
Re: How to implement User Search
« Reply #4 on: April 29, 2016, 10:42:41 pm »
teseo, there is a user filter in admin section....Users can be filtered by their Name, Username, email and location (Country, region and city). Was looking at a similar one for front end (website)

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: How to implement User Search
« Reply #5 on: April 29, 2016, 10:56:21 pm »
Yes, that code could be adapted to work on frontend, but on Admin that ends going to a page whit all ads fron that user, where and for what do you want to use this on front end? Should this end going to User Profile? ??? Please try to be more specific, I don't have much spare time lately...

Regards

itcafeonline

  • Full Member
  • ***
  • Posts: 245
Re: How to implement User Search
« Reply #6 on: April 29, 2016, 11:03:49 pm »
teseo, yes - this  should exactly work like how it works on admin section.

Example 1 - Filter just based on Region, lists all of the users from that Region, Click on individual user, it lands them on User's Public profile.
Example 2 - Filter starting with few letters of email, it shows possible choices (ajax - not sure)
Example 3 - Filter based on a complete email - Single users, click, takes to public profile.

Completely like admin, but on front end click on it takes to the User Public profile

Thanks

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: How to implement User Search
« Reply #7 on: April 29, 2016, 11:16:34 pm »
Sorry, too complicated. I was thinking of something much more simple, a search filter for ads lists.

Regards

itcafeonline

  • Full Member
  • ***
  • Posts: 245
Re: How to implement User Search
« Reply #8 on: April 29, 2016, 11:36:10 pm »
Can you point me to the admin section of the file where I can look up this code. I have looked around, but could not work out exactly.

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: How to implement User Search
« Reply #9 on: April 30, 2016, 12:02:44 am »
This code will create an input with autocomplete to be included in a form somewhere, then you'd need to build the code to do something with the selected option:

Form

Code: [Select]
            <div class="cell">
                <input id="fUser" name="user" type="text" class="fUser input-text input-actions" value="<?php echo osc_esc_html(Params::getParam('user')); ?>" />
                <input id="fUserId" name="userId" type="hidden" value="<?php echo osc_esc_html(Params::getParam('userId')); ?>" />
            </div>
            <script type="text/javascript">
                document.write('<style type="text/css"> .tabber{ display:none; } </style>');
                $(document).ready(function(){
                    $('input[name="user"]').attr( "autocomplete", "off" );
                    $('#user,#fUser').autocomplete({
                        source: "<?php echo osc_base_url(true); ?>?page=ajax&action=runhook&hook=user_search",
                        minLength: 0,
                        select: function( event, ui ) {
                            if(ui.item.id=='') {
                                return false;
                            }
                            $('#userId').val(ui.item.id);
                            $('#fUserId').val(ui.item.id);
                        }
                    });

                    $('.ui-autocomplete').css('zIndex', 10000);
                });
            </script>

***********************

functions.php (Ajax for Autocomplete)

Code: [Select]
<?php 
function cust_ajax_user_search() {
    
$users User::newInstance()->ajax(Params::getParam("term"));
    if(
count($users)==0) {
        echo 
json_encode(array(=> array('id'=> '''label' => __('No results'), 'value' => __('No results')) ));
    } else {
        echo 
json_encode($users);
    }
}

osc_add_hook('ajax_user_search''cust_ajax_user_search');
?>

Regards

itcafeonline

  • Full Member
  • ***
  • Posts: 245
Re: How to implement User Search
« Reply #10 on: April 30, 2016, 12:09:30 am »
Thank You, teseo

Pigeon

  • Sr. Member
  • ****
  • Posts: 498
remove
« Reply #11 on: May 02, 2016, 03:40:56 am »
remove
« Last Edit: July 02, 2016, 10:27:24 am by Pigeon »