Jump to content

include if variable exists in document


Branden Wagner

Recommended Posts

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?
Link to comment
Share on other sites

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....
[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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.