PHP code example of nystudio107 / craft-autocomplete
1. Go to this page and download the library: Download nystudio107/craft-autocomplete library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nystudio107 / craft-autocomplete example snippets
use nystudio107\autocomplete\events\DefineGeneratorValuesEvent;
use nystudio107\autocomplete\generators\AutocompleteTwigExtensionGenerator;
use yii\base\Event;
Event::on(AutocompleteTwigExtensionGenerator::class,
AutocompleteTwigExtensionGenerator::EVENT_BEFORE_GENERATE,
function(DefineGeneratorValuesEvent $event) {
$event->values['myVariable'] = 'value';
}
);
namespace vendor\package;
use nystudio107\autocomplete\base\Generator;
class MyAutocompleteGenerator extends Generator
{
// Override base methods
}
use nystudio107\autocomplete\Autocomplete;
use craft\events\RegisterComponentTypesEvent;
use yii\base\Event;
Event::on(Autocomplete::class,
Autocomplete::EVENT_REGISTER_AUTOCOMPLETE_GENERATORS,
function(RegisterComponentTypesEvent $event) {
$event->types[] = MyAutocompleteGenerator::class;
}
);