Skip to main content
edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
added 404 characters in body
Source Link
RobotEyes
  • 365
  • 1
  • 3
  • 12

Is it possible to get a list of all the javascript files in the libraries directory? So far I have tried using files_scan directory but it's not returning anything:

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

many thanks.

EDIT

I changed to using DRUPAL_ROOT. This gives the correct path and returns an array of js files but there is a double slash // in the uri just before the file names: /var/www/html/droop/sites/all/libraries//d3/d3.min.js

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

Is it possible to get a list of all the javascript files in the libraries directory? So far I have tried using files_scan directory but it's not returning anything:

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

many thanks.

Is it possible to get a list of all the javascript files in the libraries directory? So far I have tried using files_scan directory but it's not returning anything:

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

many thanks.

EDIT

I changed to using DRUPAL_ROOT. This gives the correct path and returns an array of js files but there is a double slash // in the uri just before the file names: /var/www/html/droop/sites/all/libraries//d3/d3.min.js

$dir = DRUPAL_ROOT . '/sites/all/libraries/';
$files = file_scan_directory($dir, "/.*\.js$/");
dpm($files);
Source Link
RobotEyes
  • 365
  • 1
  • 3
  • 12

How to get a list of all javascript files in a directory

Is it possible to get a list of all the javascript files in the libraries directory? So far I have tried using files_scan directory but it's not returning anything:

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

many thanks.