I'll try to explain this as best as I can, but what I am trying to do isn't exactly easy to explain
I have a base XML file (plugins.xml) In this file I have a root <plugins> node. Inside of that are <plugin> nodes. I have a form (deploy_form.php) which uses this XML sheet. To make it easy for people to add plugins to this application they can add some basic nodes to this xml sheet and the form will create a new checkbox option on the deploy_form.php file. Here is what code I have for the form:
PHP Code:
<?php
foreach($pluginData->plugin as $plugin){
$name = $plugin->name;
echo '
<li><input type="checkbox" value="'.$name.'_plugin" name="jquery_plugin_'.$name.'" />'.$name.'</li>
';
}
?>
My trouble however is on the next page after the user submits this form.
I need to create a new script tag for each new plugin they add. These are jQuery plugins and so they need to make new script tags one after another in a new html/php page. My application creates (among many other things) an index html or php file with default settings such as CSS, image directories, js, jQuery library etc. Here is some more PHP code:
PHP Code:
$html_temp = ''.$html_doctype.'
<html '.$html_attr.'>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>'.$html_title.'</title>
'.$css.'
'.$jquery.'
</head>
<body>
</body>
</html>
';
I use that variable in an fwrite function below. I need to do a foreach statement like this and put it after where I have the $jquery var
PHP Code:
foreach($pluginData->plugin as $plugin){
$name = $plugin->name;
$filename = $plugin->name['filename'];
$dir = $plugin->dir;
$css = $plugin->css;
$images = $plugin->images;
if(isset($_GET["jquery_plugin_$name"])){
exec("cp -r files/JavaScript/jQuery/plugins/$dir/$filename $deploy_download/js/$filename");
if(isset($css)){
}
if(isset($images)){
}
}
echo '<script type="text/javascript" src="js/'.$filename.'"></script>';
}
I took out a lot of code so it makes it easier for you guys to help so there is a lot more options going into this but I need that final echo below to be repeated for every checked checkbox the user checked for their plugin choice. So, for example, lets say they choose 2 of 3 plugins. Then there would be a total of 2 <script> tags underneath the $jquery variable that needs to be written to a final .html or .php template.