Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:51

css style sheet


Poster: pez
Dated: Tuesday December 30 2003 - 3:24:12 GMT

I currently have website to change colours to what a user has stored as a cookie.
eg
<html>
<head>
<link href="/testing/style.php" rel="stylesheet" type="text/css" />

style.php reads cookie then includes chosen stylesheet red.php, blue.php etc.

Only thing is the dhtml menu obviously keeps its colour.


What I need to know is whats the best way to change the colour of the menus according to some variable like a cookie.

Only thing I can think of is javascript in each web page which queries cookie then calls red-menu_data.js or blue-menu_data.js.
Anyone think of another way?


Poster: pez
Dated: Tuesday December 30 2003 - 4:59:51 GMT

why no one told me about onclass offclass??

I'll get mi coat


Poster: Ruth
Dated: Tuesday December 30 2003 - 5:36:59 GMT

I was just going to do that, even made example pages on how to use it in case you weren't sure on how to do it....LINK REMOVED I made 3 pages red, blue and yellow. But, just for your info, nn4 browsers being static don't read on/off class. So, although the menu comes up and uses the page colors and text colors [which I always define anyway in the body tag, just in case, it messes up on the submenus, makes it look as if there's no background color, so the text appears in the same font s the page and drops over the typed words on the page... the workaround for them is to define within the menu data file a background and text color for the submenus, say white background and black text. They'll be that color on every browser, but at least NN will show up....if your menu never drops over existing text, then you can just leave the on/off class because the submenu text shows fine. 2nd issue isi the subimages [which I just decided not to use to get away from the problem] if you define a border and use on/off class then the little arrow subimage which normally does NOT get a border will get one. Good Luck

Ruth


Poster: pez
Dated: Tuesday December 30 2003 - 6:35:50 GMT

LOL
Excellent. Thanx for the post but alas yes I'd already got there too.
Good post for all those who havent worked it out yet !


Poster: pez
Dated: Tuesday December 30 2003 - 7:21:18 GMT

OK did it like this
5 files
setcolor.htm setscookie
style.php readscookie chooses style sheet
pink-style.php
blue-style.php
menu_data.js

First edit menu_data.js
Add two lines of code


with(menuStyle=new mm_style()){
onclass="menuON"; //this bit
offclass="menuOFF"; //and this bit

//delete the onbgcolor cos your adding it in the style sheet
//delete the offbgcolor aswell
bordercolor="#296488";
etc
etc


###############
setcolor.htm
###############
<html>
<head>
<title>cooike set</title>
<link href="/styl/style.php" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
function PutCookie(name, value, hours)
{
var expire = "";
if(hours != null)
{
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire;
location.reload();
}
</script>
</head>

<body>
<SCRIPT language=JavaScript src="/milonic_src.js" type=text/javascript></SCRIPT>
<script language=JavaScript type="text/javascript">
//<![CDATA[
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=../mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript src=../mmenudom.js><\/scr"+"ipt>");
//]]>
</script>
<SCRIPT language=JavaScript src="/menu_data.js" type=text/javascript></SCRIPT>
<br><br>
<a href="#" onClick="PutCookie('cstyle','pnk',7200)" >Pink</a>
<br>
<a href="#" onClick="PutCookie('cstyle','blu',7200)" >Blue</a>
</body>
</html>
#####################

the above calls
style.php
############
<?php
if (trim(strtolower($HTTP_COOKIE_VARS['cstyle'])) == null){
include("pink-style.php");
}
elseif ($HTTP_COOKIE_VARS['cstyle'] == 'pnk'){
include("pink-style.php");
}
elseif ($HTTP_COOKIE_VARS['cstyle'] == 'blu){
include("blue-style.php");
}?>
#############

which calls either

pink-style.php
###############
<?php echo "
.menuON
{
background-color: pink;
color: white;
}
.menuOFF
{
background-color: red;
color: white;
}
body
{
background-color:pink;
}
a
{
font-family: Verdana, Lucida, Geneva, Helvetica, Arial, sans-serif;
font-size:11px;
color: green;
}";
?>
##################

blue-style.php

<?php echo "
.menuON
{
background-color: blue;
color: white;
}
.menuOFF
{
background-color: purple;
color: white;
}
body
{
background-color:blue;
}
a
{
font-family: Verdana, Lucida, Geneva, Helvetica, Arial, sans-serif;
font-size:18px;
color: orange;
}";
?>
#####################


Just previewed the above...i'm laughing.. anyway hope this helps someone


Poster: Hergio
Dated: Saturday January 3 2004 - 18:05:22 GMT

You are including different files based on something...fine and dandy, it works. But you could also set variables based on the cookies and then use those cookies in the menu_data file.

For example, you cookie contains RED so you set a variable $color to "ff0000" and then your menu_data file you could change it to a .php file and then you could say
....
bgcolor=<?echo($color)?>;
....

See what I mean? Only One file and you are just editting things in the file on the fly based on the cookies before it goes down to the browser. Hope this helps.... ;)