On my site I want to build a User Selectable layout and color scheme feature which passes the layout and color variables around the urls via a formatted string like $urlextra. While all that worked fine one of my require();'ed files variables don't seem to be globalized or available to my other scripts.
The index.php code is this:
require('lib/config.php');
include('layout.php');
$colorstr=getColors($style);
require $colorstr;
$templatestr=getTemplate($style);
require $templatestr;
require('lib/global.php');
and the getColors and getTemplate functions are defined in 'layout.php' like so:
function getColors($style) {
global $colorset_name,$c,$skin;
if ($skin=="default") {
$colorset_name="Arc-Corp Classic";
} elseif ($skin=="skin_2") {
$colorset_name="Under Development";
}
if ($colorset_name=="Arc-Corp Classic" && $style=="") {
$c='default';
} elseif ($colorset_name=="$skin2" && $style=="") {
$c='skin_2';
} elseif (isset($style)) {
$c=$style;
}
$cstring="layout/colorsets/" . $c . ".php";
return $cstring;
}
function getTemplate($style) {
global $template_name,$skin;
if ($template_name=="Arc-Corp Classic" && $style=="") {
$skin='default';
} elseif ($template_name=="$skin2" && $style=="") {
$skin='skin_2';
} elseif (isset($style)) {
$skin=$style;
}
if ($skin=="default") {
$template_name="Arc-Corp Classic";
} elseif ($skin=="skin_2") {
$template_name="Under Development";
}
$string="layout/templates/" . $skin . ".php";
return $string;
}
My variable check in the output of index.php is this:
$style =
$template_name = Arc-Corp Classic
$colorset_name = Arc-Corp Classic
$colorstr = layout/colorsets/default.php
$templatestr = layout/templates/default.php
$skin = default
$page_title = Arc-Corp: -Home-
$scrollbar =
$bgcolor =
So it indicates that colorstr is a string that points exactly to where my file supplying the variables is located on my server and because I used require as opposed to include tells me that it hasn't encountered any fatal errors. So why isn't the require working properly? The templatestr (used in the function getTemplate) worked perfectly and supplied the layout variables necessary for the content of the page (just horrendously ugly with all hex colors in one, missing, file). $scrollbar and $bgcolor were just css variables for the templates (and were also contained in layout/colorsets/default.php).
Any help would be very appreciated.