UBB.Dev
Posted By: vashavoc [question] dynamic style sheets? - 11/11/2003 5:24 AM
does ubbt support dymanic style sheet changing?
Posted By: JoshPet Re: [question] dynamic style sheets? - 11/11/2003 5:42 AM
What do you mean?

User's can select their own stylesheet and change it whenever they want - you also can define stylesheets to sepcific forums.
Posted By: vashavoc Re: [question] dynamic style sheets? - 11/11/2003 6:16 AM
well im making a site and pending if this works as planned, a user can select a color scheme (blue or ornage) and itll change the css as needed on the fly.

example: http://www.lestercat.net/dev/CSS_Demo/Alternate_Style_Sheets.html

but im curious if ubbt would allow this to function for it as well as the rest of the site. cuz it would look dumb with the rest of the site looking different than the forums imo.
Posted By: JoshPet Re: [question] dynamic style sheets? - 11/11/2003 6:20 AM
Hmm.. not sure. There would be no need to do that as each user can select their own preferences in their display prefs.

But if it's just one stylesheet that acts like that - then it should still behave like that. You'd probably need to test it to be sure.
Posted By: Astaran Re: [question] dynamic style sheets? - 11/11/2003 11:22 AM
As Josh said, users can define their style in the user preferences, but it shouln't be difficult to change with clicking a link. You don't need to do that with javascript, you could simply alter the apropriate user field in the database and reload the page.
Posted By: AllenAyres Re: [question] dynamic style sheets? - 11/12/2003 5:20 AM
For instantaneous changing, you can pre-load them with javascript... limit in your theme settings to one style then load the others with javascript as alternate styles .css
Posted By: AKD96 Re: [question] dynamic style sheets? - 11/14/2003 3:54 PM
This may help to get you started... http://www.alistapart.com/articles/alternate
Posted By: AKD96 Re: [question] dynamic style sheets? - 11/14/2003 4:35 PM
Okay, I have it working somewhat. What I did was download the script from that page and uploaded it to my server. I then added the following code to my header-insert:

Code
<script type="text/javascript" <br />src="http://www.drumlines.org/scripts/styleswitcher.js"></script> <br /> <br /><link rel="alternate stylesheet" <br />type="text/css" href="http://www.drumlines.org/betathreads/stylesheets/aqua.css" <br />title="aqua" /> <br /> <br /><link rel="alternate stylesheet" <br />type="text/css" href="http://www.drumlines.org/betathreads/stylesheets/mocha.css" <br />title="mocha" />


I then went into ubbt_header.tmpl and changed:

Code
<link rel="stylesheet" href="$stylesheet" type="text/css" />


to this:

Code
<link rel="stylesheet" href="$stylesheet" type="text/css" title="default" />


I then made a post, in HTML, of this:

Code
<a href="#" onclick="setActiveStyleSheet('aqua'); return false;">Change style to Aqua</a> <br /> <br /><a href="#" onclick="setActiveStyleSheet('mocha'); return false;">Change style to Mocha</a> <br /> <br /><a href="#" onclick="setActiveStyleSheet('default'); return false;">Change style back to your default.</a>


It affects all users, not just you. If anyone knows a thing or two about cookies, I'm sure that will solve the problem.
Posted By: AKD96 Re: [question] dynamic style sheets? - 11/14/2003 4:37 PM
P.S.
I wish I could show you an example, but it seems to affect the whole site for everyone, so I have posted it in a private area. JoshPet and Omegatron have access to tinker with it though.

P.P.S.
If you try this JoshPet and/or Omegatron, it will only work at my /betathreads install.
Posted By: AKD96 Re: [question] dynamic style sheets? - 11/14/2003 4:47 PM
Oh yeah, to answer the initial question, I hypothesise (sp) that this would work site-wide as long as the script and stylesheet headers are in every file and you use identical class tags to UBB throughout your site.
Posted By: AKD96 Re: [question] dynamic style sheets? - 11/14/2003 5:02 PM
After more hacking, I believe it probably doesn't affect all users, but rather writes the style to your cookie in such a way that the My Cookies clear does not erase it. Probably because it was not written with this in mind. So deleting your cookies will do the trick of returning everything to normal.

Again, if anyone out there has any cookie experience, I believe this will be the icing on the cake.
Posted By: AKD96 Re: [question] dynamic style sheets? - 11/14/2003 5:09 PM
You have to click back to default, then clear your cookies. It acts like it's somehow remembering what was last clicked without using a cookie. [twilight zone music /]
Posted By: omegatron Re: [question] dynamic style sheets? - 11/14/2003 5:39 PM
From initial looking it does not change every user.

Here are some tidbits from what I found and need work on.

In Internet Explorer one needs the links to click to change stylesheets.

In Mozilla there is a nice little box on the bottom left corner of window that allows you to instantly change themes.

However as expected the change a user makes is only good for one window and when the page refreshes it goes back to the user's default. Basically the javascript allows switching of the stylesheets. What needs to happen is a script to be written upon action of the stylesheet change to rewrite the user's cookie with the updated stylesheet then the change would take place on how many pages the user wanted and changing would simply be clicking the box to change it. Or of course logging out. Rewriting the cookie routine on the fly is more complicated than most things but doable using the present code in threads to another script allowing the stylsheet variable when switching to be passed to the cookie.

Since I assume 6.4 has an updated cookie routine when it goes final it might be something worthwhile to look into as far as hacks are concerned.
Posted By: AKD96 Re: [question] dynamic style sheets? - 11/14/2003 5:58 PM
Changing pages does make the default style re-appear, but then it changes to what what previously chosen upon completion of the page load.
Posted By: omegatron Re: [question] dynamic style sheets? - 11/14/2003 6:41 PM
Beg to differ

The page is loaded back to the default set by the user's cookie which is what is pulled from the database and in the intitial cookie. The problem being this mod allows switching but the user cookie is not updated.

Now the Javascript works in IE and will update the page after loading completes. However there is no nice fancy switcher in IE. One must click those links you provide.

Now in Mozilla you get a nice fancy box which allows switching on the fly. However the page when done does not reload to the alternative stylesheet.
Posted By: AKD96 Re: [question] dynamic style sheets? - 11/18/2003 3:01 PM
An update on this...

I guess I had loaded too many styles into my header, because my moderators said the site would lock-up their browser. I using about 20 or so styles, so I guess that's pushing it. Still a lot of odd behaviour by this though. Anyone else tinkering with this?
Posted By: AllenAyres Re: [question] dynamic style sheets? - 11/19/2003 9:07 AM
I plan to do it with a .classic forum, I'll let ya know what problems/fixes I see
Posted By: AKD96 Re: [question] dynamic style sheets? - 11/19/2003 1:58 PM
Thanks!
Posted By: Astaran Re: [question] dynamic style sheets? - 11/24/2003 1:03 PM
You could avoid these problems by not using javascript but php for switching the css-files. This way, your users can change the style even if they have javascript disabled.
© UBB.Developers