Using input/autocomplete with elgg_view

Hi,

I'm trying to create a view that uses the "input/autocomplete" text input.

The code in this test view is:

<div class="contentWrapper">
<form action="<?php echo $vars['url']; ?>action/issues/new" enctype="multipart/form-data" method="post">
        <?php echo elgg_view('input/securitytoken'); ?>
        <p>
                <label><?php echo elgg_echo("issues:icon"); ?><br />
                <?php
                        echo elgg_view("input/autocomplete",array('internalname' => 'issuer','match_on'=>'group'));
                ?>
                </label>
        </p>
                <input type="submit" class="submit_button" value="<?php echo elgg_echo("save"); ?>" />
        </p>
</form>
</div>

 

And the generated code seems to look OK - except that it does not pick out matching groups - the little ticker spins but nothing shows up. I cant find any other reference to sample code on google for input/autocomplete so does this work?

 

Thanks

 

 

  • Well if nothing is coming up obviously it isn't working.

    There are a number of autocomplete plugins available in the plugin repo. My advice is test them all out and see if you can get any of them to work. If not then it may be something to do with your customization of the groups plugin.

    Good luck!

  • Ta - I've gone with the libforms_utils plugin.

  • I think the autocomplete view is broken.

  • it's been fixed since 1.7.10 (if not earlier) due to it searching on a wrong page_handler. However I do have an issue with this input at the moment, which is how to use the "match_on" option with a specific subtype.

    I can't quite seem to work out the required coding to make it work. It says it needs an array, but what's that supposed to look like?

    The following works fine:

    echo elgg_view('input/autocomplete', array('match_on' => 'all')) . "<br>";

    but none of the following work:
    echo elgg_view('input/autocomplete', array('match_on' => array('group'))) . "<br>";
    echo elgg_view('input/autocomplete', array('match_on' => array('types' => 'object', 'subtypes' => 'word'))) . "<br>";
    Can anyone enlighten me as to the proper code to get it to match on a specific entity subtype?
  • Looks like the documentation in the view is incorrect. It should be "groups", not "group". 

    It also seems that using autocomplete for object/<subtype> is not supported by the livesearch page handler: http://trac.elgg.org/ticket/3620

  • well the groups|users|all options work fine, but yes the page_handler doesn't seem to be able to deal with object/<subtype> at the moment. I will look into that as it would be very useful to get that working.

  • @Cash: while this is by no means a fix for the problem, I wonder if you would have an idea about how to set a search on a specific subtype. I've never looked at mysql querying before. The following code isn't working, but perhaps you might spot the reason why?

     

    case 'words':

    // don't return results if groups aren't enabled.

    $query = "SELECT * FROM {$CONFIG->dbprefix}entities as e

    WHERE e.type = 'object'

    AND e.subtype = '43'

    AND (e.title LIKE '$q%' OR e.description LIKE '%$q%')

    LIMIT $limit

    ";

    if ($entities = get_data($query)) {

    foreach ($entities as $entity) {

    $json = json_encode(array(

    'type' => 'object',

    'subtype' => 'word',

    'desc' => strip_tags($entity->description),

    'guid' => $entity->guid

    ));

    //$results[$entity->name . rand(1,100)] = "$json|{$entity->guid}";

    $results[$entity->title . rand(1,100)] = $json;

    }

    }

    break;

     

  • The title and description are in the object entities table. You would need to do a join to do that query.

  • @Trajan,

    Take a look at hypeLiveSearch. I've done some modifications to autocomplete and its page_handler. Perhaps you can gather some ideas there.

  • @both:  thanks for the thoughts.

    @ihayredinov: I've found your new case for objects (just what I was looking for). What's the coding needed in the hypeautocomplete view for match_on to select a specific subtype?

    ''match_on' => 'objects' ??????