Printable Version of Topic

Click here to view this topic in its original format

-=Reborn JEDI=- Forums _ phpTalk _ Now You See It, Now You Don't

Posted by: InfiniteWarrior Oct 2 2005, 02:58 PM

For the option to turn styles off and on, I'm using this little snippet:

CODE
<?php
if( $_GET['css'] != 'false' )
{
?>
 <link rel="stylesheet" href="style.css" type="text/css" />
<?php
}
?>


... and the links:

CODE
<a href="?css=false">Styles Off</a> | <a href="?css=true">Styles On</a>


... meaning both links are visible at all times. What I'd like to do is make one or the other disappear depending on which has been selected: "Styles Off" becomes "Styles On" and vice versa.

Any of you youngsters wanna help out an old lady?

Posted by: Kyzene Oct 2 2005, 06:51 PM

Reading all that crazyness made my brain hurt. C++ is so much more...normal rolleyes.gif

Posted by: Ruggiero Oct 2 2005, 06:56 PM

I KNOW Liz has seen this thread.... I just don't know if he knows the answer. wink.gif

Rugg

Posted by: TheLizardKing Oct 2 2005, 07:05 PM

well what you could do is decide what you would like to have set by default. If you want css on by default you should then just simply write some code that says something like.

<?php

if (isset($_GET['css'])) {
$headercss = "<link rel="stylesheet" href="style.css" type="text/css" />"

$linktext = "<a href=blah.php?css=false">Styles Off</a>"
} else {
$linktext = "<a href=blah.php">Styles On</a>"
}

?>

And place the appropriate $variables where ye need them to be.

Posted by: InfiniteWarrior Oct 2 2005, 10:03 PM

Thanks for the edification, Msr. Lizard. 'Twould be on by default. I'll try it.

Please forgive my PHP illiteracy, but how might one write those appropriate variables when placing them? Also, I'd like "off" to refresh any page the user happens to be on and have it stay that way until the "on" link was clicked again (from anywhere), but I'm thinking a cookie would be necessary to carry the preference. Will this code avoid that?

Posted by: TheLizardKing Oct 3 2005, 09:53 PM

For the variables, all you have to do is place that bit of code (its not 100% syntax correct) near the top and place the header variable in the header and the link variable where the link is

html <?php echo $linktext; ?> morehtml

and for the persistant memory, you are gonna want to look into sessions. Unfortunately I am not the master of sessions so I can't help much there sad.gif

Posted by: InfiniteWarrior Oct 4 2005, 06:08 PM

Ah, dat's ok. Should have seen the sessions coming, but I have a lifeline for those. Thank you ever so much!

~ Infi

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (WDYL-WTN Release)