Skip to main content
explained code sample
Source Link
autopoietic
  • 1.7k
  • 9
  • 26

libraries_get_libraries should return an array of library directories, with the library name as the key and the directory as the value.

libraries_get_path will get you the path to a specific library (js).

Follwing your approach, this works fine for me:

  $dir = "sites/all/libraries";
  $files = file_scan_directory($dir, '/.*\.js$/');

I think it might be base_path that is breaking it in your example, as it adds a / in front of the (relative) path from the site root.

Combining libraries_get_libraries with file_scan_directory will also get you libraries from profile and site specific directories:

$libraries_array = libraries_get_libraries();
foreach($libraries_array as $library => $directory) {
  $files = file_scan_directory($directory, '/.*\.js$/');
  $js_paths[$library] = $files;
}
dpm($js_paths);

It may be worth noting that these libraries may contain many javascript files that are not actually used by modules.

libraries_get_libraries should return an array of library directories, with the library name as the key and the directory as the value.

libraries_get_path will get you the path to a specific library (js).

Follwing your approach, this works fine for me:

  $dir = "sites/all/libraries";
  $files = file_scan_directory($dir, '/.*\.js$/');

I think it might be base_path that is breaking it in your example, as it adds a / in front of the (relative) path from the site root:

$libraries_array = libraries_get_libraries();
foreach($libraries_array as $library => $directory) {
  $files = file_scan_directory($directory, '/.*\.js$/');
  $js_paths[$library] = $files;
}
dpm($js_paths);

It may be worth noting that these libraries may contain many javascript files that are not actually used by modules.

libraries_get_libraries should return an array of library directories, with the library name as the key and the directory as the value.

libraries_get_path will get you the path to a specific library (js).

Follwing your approach, this works fine for me:

  $dir = "sites/all/libraries";
  $files = file_scan_directory($dir, '/.*\.js$/');

I think it might be base_path that is breaking it in your example, as it adds a / in front of the (relative) path from the site root.

Combining libraries_get_libraries with file_scan_directory will also get you libraries from profile and site specific directories:

$libraries_array = libraries_get_libraries();
foreach($libraries_array as $library => $directory) {
  $files = file_scan_directory($directory, '/.*\.js$/');
  $js_paths[$library] = $files;
}
dpm($js_paths);

It may be worth noting that these libraries may contain many javascript files that are not actually used by modules.

addition
Source Link
autopoietic
  • 1.7k
  • 9
  • 26

libraries_get_libraries should return an array of library directories, with the library name as the key and the directory as the value.

libraries_get_path will get you the path to a specific library (js).

Follwing your approach, this works fine for me:

  $dir = "sites/all/libraries";
  $files = file_scan_directory($dir, '/.*\.js$/');

I think it might be base_path that is breaking it in your example, as it adds a / in front of the (relative) path from the site root:

$libraries_array = libraries_get_libraries();
foreach($libraries_array as $library => $directory) {
  $files = file_scan_directory($directory, '/.*\.js$/');
  $js_paths[$library] = $files;
}
dpm($js_paths);

It may be worth noting that these libraries may contain many javascript files that are not actually used by modules.

libraries_get_libraries should return an array of library directories, with the library name as the key and the directory as the value.

libraries_get_path will get you the path to a specific library (js).

Follwing your approach, this works fine for me:

  $dir = "sites/all/libraries";
  $files = file_scan_directory($dir, '/.*\.js$/');

I think it might be base_path that is breaking it in your example, as it adds a / in front of the (relative) path from the site root.

libraries_get_libraries should return an array of library directories, with the library name as the key and the directory as the value.

libraries_get_path will get you the path to a specific library (js).

Follwing your approach, this works fine for me:

  $dir = "sites/all/libraries";
  $files = file_scan_directory($dir, '/.*\.js$/');

I think it might be base_path that is breaking it in your example, as it adds a / in front of the (relative) path from the site root:

$libraries_array = libraries_get_libraries();
foreach($libraries_array as $library => $directory) {
  $files = file_scan_directory($directory, '/.*\.js$/');
  $js_paths[$library] = $files;
}
dpm($js_paths);

It may be worth noting that these libraries may contain many javascript files that are not actually used by modules.

addition
Source Link
autopoietic
  • 1.7k
  • 9
  • 26

libraries_get_libraries should return an array of library directories, with the library name as the key and the directory as the value.

libraries_get_path will get you the path to a specific library (js).

Follwing your approach, this works fine for me:

  $dir = "sites/all/libraries";
  $files = file_scan_directory($dir, '/.*\.js$/');

I think it might be base_path that is breaking it in your example, as it adds a / in front of the (relative) path from the site root.

libraries_get_libraries should return an array of library directories, with the library name as the key and the directory as the value.

libraries_get_path will get you the path to a specific library (js).

libraries_get_libraries should return an array of library directories, with the library name as the key and the directory as the value.

libraries_get_path will get you the path to a specific library (js).

Follwing your approach, this works fine for me:

  $dir = "sites/all/libraries";
  $files = file_scan_directory($dir, '/.*\.js$/');

I think it might be base_path that is breaking it in your example, as it adds a / in front of the (relative) path from the site root.

correction
Source Link
autopoietic
  • 1.7k
  • 9
  • 26
Loading
Source Link
autopoietic
  • 1.7k
  • 9
  • 26
Loading