beaux1 Posted February 15, 2007 Share Posted February 15, 2007 Hey. On my site, I got coded a CSS Style changer. The code is as following: <?php //Simple CSS changer thingy for trevorchan //by Smurph //cookie value and filename must be the same! (cookie value must lack .css at the end) require('config.php'); function css_menu_getcookie() { if ($_COOKIE['menucss']) { return '<LINK REL=StyleSheet HREF=\"'. $tc_webpath . '/css/' . $_COOKIE['menucss'] . '.css\" TYPE="text/css">\n'; } else { return '<LINK REL=StyleSheet HREF=\"'. $tc_webpath . '/css/' . $tc_defaultmenucss . '.css\" TYPE="text/css">\n'; } //returns the full path to the selected css script (I.E. http://www.pchan.org/css/futaba.css) within a HTML LINK tag } function css_board_getcookie() { if ($_COOKIE['boardcss']) { return '<LINK REL=StyleSheet HREF=\"'. $tc_webpath . '/css/' . $_COOKIE['boardcss'] . '.css\" TYPE="text/css">\n'; } else { return '<LINK REL=StyleSheet HREF=\"'. $tc_webpath . '/css/' . $tc_defaultboardcss . '.css\" TYPE="text/css">\n'; } //returns the full path to the selected css script (I.E. http://www.pchan.org/css/futaba.css) within a HTML LINK tag } if ($_GET['menucss']) setcookie('menucss', $_GET['menucss'], 60 * 60 * 24 * 60 + time()); if ($_GET['boardcss']) setcookie('boardcss', $_GET['boardcss'], 60 * 60 * 24 * 60 + time()); ?> I have my values set in config.php: $tc_defaultmenucss= 'pchanm'; $tc_defaultboardcss= 'pchan'; In menu.php, I have the code to call the CSS, which is as follows: <?php require('config.php'); require($tc_config['rootdir'].'/inc/functions.php'); require('css.php'); ob_start() ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title><?php echo $chan_name; ?> Navigation</title> <?php css_menu_getcookie(); ?> However, the CSS doesn't show on the navigation. Anyone know why? No errors show, there's just no CSS. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted February 15, 2007 Share Posted February 15, 2007 Look at the browser code for your page...I bet the css link line looks something like: <LINK REL=StyleSheet HREF=\"/css/pchanm.css\" TYPE="text/css">\n Change the single quotes to double around your echo statements... function css_menu_getcookie() { if ($_COOKIE['menucss']) { return "<LINK REL=StyleSheet HREF=\"". $tc_webpath . "/css/" . $_COOKIE['menucss'] . ".css\" TYPE=\"text/css\">\n"; } or reverse the quotes.... function css_menu_getcookie() { if ($_COOKIE['menucss']) { return '<LINK REL=StyleSheet HREF="'. $tc_webpath . '/css/' . $_COOKIE['menucss'] . '.css" TYPE="text/css">' . "\n"; } The single quotes will cause the "\n" to be taken literally, so it will output \n rather than a newline character. Quote Link to comment 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.