Custom Callback URL exemple

Created on 4 November 2016, about 8 years ago
Updated 3 July 2023, over 1 year ago

Thanks for the module.
I use it for two websites and it works great with views.

Now, i want to implement my custom callback URL for better performance and mixing entity.

Can you have some exemple of implantation with a custom function ? Some documentation ? I have searched here and on your website, but i find nothing about it...

I have create a URL (autocomplete_mylist) with hook_menu and call a custom function (_my_autocomplete).
My custom function returns a json buth there is no filter apply. So, when i fill my input with my text, all the result apears.

I miss something o_0

This is my custom code in a custom module :

function custom_module_menu() {
  $items['autocomplete_mylist'] = array(
    'page callback' => '_my_autocomplete',
    'access arguments' => array('access content'),
   'access callback' => TRUE,
   'type' => MENU_CALLBACK
  );
  return $items;
}
function _my_autocomplete() {
  $matches = array();
  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', 'taxonomy_term')
        ->entityCondition('bundle', array('tag'))
        ->propertyOrderBy('weight');
  $result = $query->execute();
  $tids = array_keys($result['taxonomy_term']);
  foreach ($tids as $key => $tid) {
    $term_object = taxonomy_term_load($tid);
    $name = $term_object->name;
    $matches[]=array("link"=>'/hello',"label"=>$name,"value"=>$name);
  }
drupal_json_output($matches);
Feature request
Status

Closed: outdated

Version

4.7

Component

Code

Created by

🇫🇷France laborouge

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024