I am working on a drupal-7 project that have many CSS/JS files that need to be added dynamically.
This is the code which i am using in mymodule_init()
function doLookup($baseRootDir)
{
if (variable_get('xmldata')) {
$xmldata = variable_get('xmldata');
} else {
$xmldata = '';
}
$rootDir = realpath($baseRootDir . DIRECTORY_SEPARATOR . $xmldata);
$di = new RecursiveDirectoryIterator($rootDir);
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
$fileInfo = new SplFileInfo($filename);
if (strtolower($fileInfo->getExtension()) == "css") {
// Include this CSS file in drupal
drupal_add_css($cssFileName, array('type' => "file", 'group' => CSS_DEFAULT, 'every_page' => TRUE));
} elseif (strtolower($fileInfo->getExtension()) == "js") {
// Include this JS file in drupal
}
}
}
I am calling this function in hook_init()
which doesn't seem to be working. I have tried clearing drupal cache as well.
Please help me out i need to complete this asap :(
if
condition as well. Also what is suspicious in this dir scan please let me know if i am doing something wrong. – Raja Dushyant Oct 8 '14 at 5:31hook_init()
. – Raja Dushyant Oct 10 '14 at 5:51