Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jun 2002
Posts: 9
Lurker
Lurker
Offline
Joined: Jun 2002
Posts: 9
does ubbt support dymanic style sheet changing?

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
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.

Joined: Jun 2002
Posts: 9
Lurker
Lurker
Offline
Joined: Jun 2002
Posts: 9
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.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
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.

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
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.

Sponsored Links
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
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


- Allen wavey
- What Drives You?
Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
This may help to get you started... http://www.alistapart.com/articles/alternate

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
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.

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
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.

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
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.

Sponsored Links
Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
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.

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
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 /]

Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
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.

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
Changing pages does make the default style re-appear, but then it changes to what what previously chosen upon completion of the page load.

Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
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.

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
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?

Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
I plan to do it with a .classic forum, I'll let ya know what problems/fixes I see


- Allen wavey
- What Drives You?
Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
Thanks!

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
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.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Posts: 70
Joined: January 2007
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)