Branden Wagner Posted July 27, 2006 Share Posted July 27, 2006 I dont know if this can be done... or should be done.ive written a module system, and at the moment you have to go to mod_settings.inc and make each line$mod_name = "";$mod_type = ""; // cust,admin,billing,extra,other$enabled = 1 // 0 or 1is there a way i can include a file based on whether it contains those variables. all modules are stored in the modules directory.and i want to include all files which have $mod_type="cust"; in my customer modules list.ideas? Quote Link to comment https://forums.phpfreaks.com/topic/15776-include-if-variable-exists-in-document/ Share on other sites More sharing options...
corbin Posted July 27, 2006 Share Posted July 27, 2006 I'm not sure what you mean. Do you mean you have the folder modules then it has other folders? And you want it to look for $mod_type in every file? Quote Link to comment https://forums.phpfreaks.com/topic/15776-include-if-variable-exists-in-document/#findComment-64494 Share on other sites More sharing options...
Branden Wagner Posted July 27, 2006 Author Share Posted July 27, 2006 yes, i want it to include the fileinclude($module);but only if in the file i wish to include the variable $mod_type = "cust" exists else ignore it...if($mod_type == "cust") # is contain{ include($module) }but i figure im going to do it this way....[code]$dir = MODULES ."/". $type ;if (is_dir($dir)){ if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if($file != "." && $file != "..") { include_once($file); } } closedir($dh); }}[/code]so if they dont specify which module they want they get the generic.... but now i will just split up the modules into folders by type and this should fix it..sooo.. uhh.. just ignore my question i just answered it myself.. i just had to think a bit longer Quote Link to comment https://forums.phpfreaks.com/topic/15776-include-if-variable-exists-in-document/#findComment-64497 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.