Jump to content

CSS Styles Changer


beaux1

Recommended Posts

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.

 

 

Link to comment
Share on other sites

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.

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.