PHPackages                             hypejunction/elgg\_tokeninput - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. hypejunction/elgg\_tokeninput

AbandonedArchivedElgg-plugin[Search &amp; Filtering](/categories/search)

hypejunction/elgg\_tokeninput
=============================

Tokenizing autocomplete for Elgg

4.1.3(9y ago)126275[3 issues](https://github.com/hypeJunction/elgg_tokeninput/issues)5GPL-2.0PHP

Since Jan 15Pushed 9y ago5 watchersCompare

[ Source](https://github.com/hypeJunction/elgg_tokeninput)[ Packagist](https://packagist.org/packages/hypejunction/elgg_tokeninput)[ Docs](http://hypejunction.com)[ RSS](/packages/hypejunction-elgg-tokeninput/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (14)Used By (5)

Tokenizing Autocomplete for Elgg
================================

[](#tokenizing-autocomplete-for-elgg)

[![Elgg 2.0](https://camo.githubusercontent.com/981b94044a74b931be93e2825c7151896de9c8a53ccb960daf01b8fe0d800774/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f456c67672d322e302e782d6f72616e67652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/981b94044a74b931be93e2825c7151896de9c8a53ccb960daf01b8fe0d800774/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f456c67672d322e302e782d6f72616e67652e7376673f7374796c653d666c61742d737175617265)

Replacement for Elgg's core autocomplete and userpicker

Screenshots
-----------

[](#screenshots)

[![alt text](https://camo.githubusercontent.com/a4f49e851c02708adfc12e2ebcbf7c119bf46d1480421a436cae0b57de5dd354/68747470733a2f2f7261772e6769746875622e636f6d2f687970654a756e6374696f6e2f656c67675f746f6b656e696e7075742f6d61737465722f73637265656e73686f74732f746f6b656e696e7075742e706e67 "Tokeninput")](https://camo.githubusercontent.com/a4f49e851c02708adfc12e2ebcbf7c119bf46d1480421a436cae0b57de5dd354/68747470733a2f2f7261772e6769746875622e636f6d2f687970654a756e6374696f6e2f656c67675f746f6b656e696e7075742f6d61737465722f73637265656e73686f74732f746f6b656e696e7075742e706e67)

Features
--------

[](#features)

- User-friendly autocomplete and userpicker inputs
- Works with entities and meta tags
- Developer-friendly
- Single and multiple selection
- Free tagging
- Drag&amp;Drop sorting of tokens

Notes
-----

[](#notes)

### I/O

[](#io)

Default behavior of the JS plugin is to implode user input into a comma-separated string. PHP plugin hook for 'action', 'all' will attempt to explode these values and feed them back into an action for further processing. This however, will only work with basic form input names, e.g. `name="field_name"`If you are working with more complex forms, where e.g. `name="field_name[element_name]"`, you will need to add some custom logic to your action.

### AJAX requests

[](#ajax-requests)

To initialize a tokeninput upon successfull AJAX request, use `$('.elgg-input-tokeninput').trigger('initialize');`

### Results and Token Format

[](#results-and-token-format)

#### Server Side

[](#server-side)

Use `'tokeninput:entity:export', $entity_type` plugin hook to modify json output. You can add 'html\_result' and 'html\_token' parameters to customize the output.

#### Client Side

[](#client-side)

Use `'results:formatter', 'tokeninput'` and `'results:formatter', 'tokeninput'`hooks.

Examples
--------

[](#examples)

### Example 1

[](#example-1)

*Create an input that would allow users to search and select multiple files to be attached to an entity:*

Add an input to the form:

```
echo elgg_view('input/tokeninput', array(
		'value' => $current_attachment_guids, // An array of values (guids or entities) to pre-populate the input with
		'name' => 'attachment_guids',
		'callback' => 'my_search_files_callback',
		'query' => array('simpletype' => 'image'),
		'multiple' => true
	));
```

Add a callback function:

```
function my_search_files_callback($query, $options = array()) {

	$user = elgg_get_logged_in_user_entity();
	$simpletype = get_input('simpletype');

	$query = sanitize_string($query);

	// replace mysql vars with escaped strings
	$q = str_replace(array('_', '%'), array('\_', '\%'), $query);

	$dbprefix = elgg_get_config('dbprefix');

	$options['types'] = array('object');
	$options['subtypes'] = array('file');
	$options['joins'][] = "JOIN {$dbprefix}objects_entity oe ON oe.guid = e.guid";
	$options['wheres'][] = "oe.title LIKE '%$q%'";
	$options['wheres'][] = "e.owner_guid = $user->guid";

	if ($simpletype) {
		$options['metadata_name_value_pairs'] = array(
			'name' => 'simpletype', 'value' => $simpletype
		);
	}

	return elgg_get_entities_from_metadata($options);

}
```

In your action file:

```
$attachment_guids = get_input('attachment_guids');
if (is_string($attachment_guids)) {
	$attachment_guids = explode(',', $attachment_guids);
}
if (is_array($attachment_guids)) {
	foreach ($attachment_guids as $attachment_guid) {
		make_attachment($entity->guid, $attachment_guid);
	}
}
```

Upgrades
--------

[](#upgrades)

To 4.x
------

[](#to-4x)

- `elgg.tokeninput` library has been removed. `elgg_load_library('elgg.tokeninput')` calls will WSOD, just remove them
- `tokeninput/init` AMD module has been removed. Tokeninput is bootstrapped as needed on page load and on ajax requests.
- `define('ELGG_TOKENINPUT_PAGEHANDLER', 'tokeninput');` has been removed. If you need to modify page handler identifier, unregister the page handler and register a new one

Attributions / Credits
----------------------

[](#attributions--credits)

- jquery.tokeninput

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~58 days

Recently: every ~77 days

Total

13

Last Release

3431d ago

Major Versions

3.3.0 → 4.0.12015-10-08

3.3.2 → 4.0.22016-01-24

3.x-dev → 4.1.22016-08-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/5071b1cd852e094b3f564962a625e04c227adc73af30c5b46b243ab8f20154a7?d=identicon)[hypeJunction](/maintainers/hypeJunction)

---

Top Contributors

[![hypeJunction](https://avatars.githubusercontent.com/u/1202761?v=4)](https://github.com/hypeJunction "hypeJunction (96 commits)")

---

Tags

pluginsearchautocompleteelgg

### Embed Badge

![Health badge](/badges/hypejunction-elgg-tokeninput/health.svg)

```
[![Health](https://phpackages.com/badges/hypejunction-elgg-tokeninput/health.svg)](https://phpackages.com/packages/hypejunction-elgg-tokeninput)
```

###  Alternatives

[webdevstudios/cmb2-post-search-field

Custom field for CMB2 which adds a post-search dialog for searching/attaching other post IDs.

6647.7k2](/packages/webdevstudios-cmb2-post-search-field)[10up/debug-bar-elasticpress

Extends the Debug Bar plugin for usage with ElasticPress

2917.0k](/packages/10up-debug-bar-elasticpress)[marcorieser/statamic-live-search

A Statamic Live Search realized with Laravel Livewire.

2210.5k](/packages/marcorieser-statamic-live-search)[keygenqt/yii2-autocomplete-ajax

A simple way to search model id of the attributes model

1015.8k](/packages/keygenqt-yii2-autocomplete-ajax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
