Jump to content

Recommended Posts

I'm getting the same in IE7, FF, and Safari.

 

When you click "Autumn" it changes just fine, but then if you click the next page it defaults back to "summer.css" as you can see in the source file. This is how I ultimately check which css file it's loading.

Ooooh, I see! Right, so you want it to be cross-page compatible? Right then, you have 2 options:

 

- Either change your links to add the $_GET extention. Ooor...

 

<?php

session_start();

$seasons = array (
'spring' => array('March', 'April', 'May'),
'summer' => array('June', 'July', 'August'),
'autumn' => array('September', 'October', 'November'),
'december' => array('December', 'January', 'February')
);

if(isset($_GET['css']) && array_key_exists($_GET['css'], $seasons)) {
$css = $_GET['css'];
$_SESSION['css'] = $_GET['css'];
} elseif(isset($_SESSION['css'] && array_key_exists($_SESSION['css'], $seasons)) {
$css = $_SESSION['css'];
} else {
foreach($seasons as $season) {
if(in_array(date('F'), $season)) {
$css = $season;
$_SESSION['css'] = $season;
}
}
}

 

EDIT: Made a small change

 

----------------

Now playing: Enter Shikari - Closing

via FoxyTunes

if (!isset($_GET['css'])) {
if ($date >= 4 && $date <= 5 || $css == 'spring'){ ?>
<link rel="stylesheet" href="/_stylesheets/spring.css" type="text/css" media="screen" />
<? } elseif ($date >= 6 && $date <= 8 || $css  == 'summer') { ?>
<link rel="stylesheet" href="/_stylesheets/summer.css" type="text/css" media="screen" />

 

if $_GET['css'] is not set and month is between 6 & 8 ( which it is actually as it is July now), it will show summer as css.....

 

Where is $css initialized? i cannot see it in the code of your first post.

 

 

basically i think you should do something like this...

 

<?php
//remove this line from top....
//$_SESSION["css"] = ($_GET['css']);

//try following code

//First priority, check if $_GET is set

$css = "default";

if(isset($_GET['css']) && in_array($_GET['css'], array('spring', 'summer', 'autumn', 'winter'))) {
 $css = $_GET['css'];
 $_SESSION["css"] = $css; 
} 
// Second priority from $_SESSION
else if(isset($_SESSION["css"])) {
 $css = $_SESSION['css'];

} 
//third priority css by date
else {
 $date = date("n");
 if ($date >= 4 && $date <= 5){ $css = "spring";} 
 elseif ($date >= 6 && $date <= { $css = "summer";}
 elseif ($date >= 9 && $date <= 10){ $css = "autumn";}
 elseif ($date >= 11 || $date <= 5){ $css = "winter";}
 else $css = "screen";
}
?>

<link rel="stylesheet" href="/_stylesheets/<?php echo $css; ?>.css" type="text/css" media="screen" />

 

 

 

 

 

ya ya, it has to keep the selection so it's like the user can say, "I would rather look at this whole site in winter pictures" if they wanted and not have to click it on every page.

 

I don't think I can change all the links as there are way to many....but...the code you posted gives me the following error.

 

Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in /home/mmmyeahc/public_html/community/community.php on line 14

 

This is the code I have on the index.php page.

 

<?php
session_start();
$section='community';
$seasons = array (
'spring' => array('March', 'April', 'May'),
'summer' => array('June', 'July', 'August'),
'autumn' => array('September', 'October', 'November'),
'december' => array('December', 'January', 'February')
);

if(isset($_GET['css']) && array_key_exists($_GET['css'], $seasons)) {
$css = $_GET['css'];
} elseif(isset($_SESSION['css'] && array_key_exists($_SESSION['css'], $seasons)) {
$css = $_SESSION['css'];
} else {
foreach($seasons as $season) {
if(in_array(date('F'), $season)) {
$css = $season;
$_SESSION['css'] = $css;
}
}
}
include('../_includes/top.php');
?>

<div id="content-preview">
           
           <p class="italic">Engage, Inspire...</p>
           <p><a class="more" href="community.php" title="community">More...</a></p>
           
           </div>

<?PHP
include('../_includes/bottom.php');
?>
           

Yes sorry, I understand now. My keyboard is being a bit weird, and the backspace gets stuck. I must've clicked there by accident, because it's fine on my local server :P I hope that's the only error, haha

 

----------------

Now playing: Enter Shikari - Closing

via FoxyTunes

Ya, that's the one I am trying.

 

The community section should stay now http://www.mmmyeah.com/community/

 

If this is the case...then sir....you have made my week!

 

Lemon...I don't even wanna know why you have a sticky keyboard! :P

It works for me :) Oh, and delete the echo line, it's displaying 'autumn' in the top left corner :P

 

EDIT: Well, actually, the session's season value :P

 

----------------

Now playing: Enter Shikari - Closing

via FoxyTunes

Hmmm... it seems to be working, and it seems to default back to the summer when I come back to the page in IE... but not in FF.

 

Just for my own knowledge...do all the browsers need to be closed to restart a session? Meaning if I have 3 FF browsers open, will it keep the session until they're all closed?

Ahh...ok then.

 

Cool!

 

Well everyone...I'm not so cranky now! :D

 

I want to thank everyone for their help getting this going. I truly appreciate all the effort put in by all especially LemonInFlux and samshel!!

 

I suppose I can call this one solved! And I suppose I can actually sleep now! :D

Haha, no problem. I always get a geeky sense of accomplishment when I solve a problem :P Now quick, click the topic solved button before hundreds of people start shouting :P

 

----------------

Now playing: Enter Shikari - Kickin' Back On The Surface Of Your Cheeks

via FoxyTunes

You guys don't even know how much it helped. This was the last project I had to do and then I have a three week vacation....but more importantly, I am moving out of this place in two days so I wouldn't be able to finish this site for the client until I got back...and the deadline in Tuesday.

 

So, by the skin of my teeth you guys saved my butt! :D

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.