1

http://simplytest.me/ allows you to search all existing modules. I'm trying to implement a widget with the same functionality, but I'm stuck on how to browse all the projects on drupal.org... Can someone point me in the right direction? I found the module "project_browser", but can't seem to figure out how they accomplish it...

0

2 Answers 2

3

This excellent script written by rocketeerbkw will create a text file containing the name of every d.o contrib module, giving you everything you need to get started:

/**
 * Download a full list of all modules on drupal.org by using the API. More info
 * at https://www.drupal.org/about-drupalorg/api.
 */
$url = 'https://www.drupal.org/api-d7/node.json?type=project_module';
$modules = array();
do {
  print $url . PHP_EOL;
  $options = array(
    'http' => array(
      'user_agent' => 'get_list_of_modules.php from https://github.com/rocketeerbkw/drupal_function_stats',
      'header' => 'Accept: application/json',
    ),
  );
  $context = stream_context_create($options);
  $response = file_get_contents($url, false, $context);
  $data = json_decode($response);
  foreach ($data->list as $module) {
    $modules[] = $module->field_project_machine_name;
  }
  $url = isset($data->next) ? $data->next : FALSE;
  // The next links are always provided without a format [#2253947].
  // Formatless URLs are 301 redirected to format URLs but strip all query
  // query parameters [#2364755].
  $url = str_replace('node?', 'node.json?', $url);
} while ($url);
$file = fopen('project_usage.txt', 'w');
fwrite($file, implode("\n", $modules));
fclose($file);

An example output is here:

https://raw.githubusercontent.com/rocketeerbkw/drupal_function_stats/master/project_usage.txt

Once you've got that data the only tasks are deciding where/how to store it, and creating the UI to manage it.

1
  • Thanks! This is what I needed! To the point... instead of people whining that I'm asking for a big chunk of code or a book...
    – Robin
    Nov 20, 2014 at 15:34
0

You are looking for Project Browser Server module. Please read the documentation.

This module provides an API as well as endpoints so that you can serve search results to the Module / Theme Browser module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.