Jump to content


Photo

include if variable exists in document


  • Please log in to reply
2 replies to this topic

#1 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 27 July 2006 - 04:12 AM

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 1

is 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?

#2 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 27 July 2006 - 04:32 AM

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?
Why doesn't anyone ever say hi, hey, or whad up world?

#3 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 27 July 2006 - 04:37 AM

yes, i want it to include the file

include($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....
$dir = MODULES ."/". $type ;
if (is_dir($dir))
{
        if ($dh = opendir($dir))
        {
                while (($file = readdir($dh)) !== false)
                {
                        if($file != "." && $file != "..")
                        { include_once($file); }
                }
                closedir($dh);
        }
}

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users