Hi Kirsten,
solbjerg wrote:In short: I'm asking for help to put some code referring to the doSkin function mentioned above to the main menu.
I'm afraid it wouldn't be nearly that simple.
If I understand the goal correctly, you want to be able to have the same skin applied to html pages as is used when the user is on your forums, correct? Looking at the main menu code you posted from the forum pages, it seems that the only "skinned" property in the forum's main menu is the image property for each menu item. The main menu in the html pahes uses the images from the "default" skin.
Following the same methods as those used on the forum pages, you could do what you want much more easily if your non-forum pages were .asp instead of .html. The .asp pages are run through the asp parser on the web server, when being served to the browser. So the html and javascript code that hits the browser (the client), already contains the correct image paths to the skin images; i.e., someone viewing the source on their browser would see something like
image=images/skin/skinName/icon_home.gif instead of
image=images/skin/<%= +skin+ "/"%>icon_home.gif. In other words, the variability (skins in this case) is taken care of on the server side,
before the page hits the browser. Plain old .html pages can't do that. (I don't know how much you know about asp ... probably more than me, so excuse the basic explanation!)
So, here's the thing... without using .asp on your non-forum pages, you won't be able to take advantage of the forum's skinning functions the same way. For example, you could call the doSkin() function from a menu item (or anywhere else on the page), but doing so would not have the desired effect. First, the doSkin() function requires a parameter to be passed: the selected skin. To let the user select a skin, you'd have to have some sort of equivalent to the drawSkinSelector() function that creates the Skin Selector control on your forum pages. This could set a javascript variable to the preferred skin ('brown', 'darkblue', etc.), and then pass that variable to the doSkin() function. But then you run into another trap: even if you set the preferred skin on the client side (in a js variable), the doSkin() function calls reload() at the end, to reload the page; this makes perfect sense for an asp page, because the server would re-serve the page with the new skin, using the asp statements. But it's a huge problem for a plain .html page, because a js variable set in a page only exists as long as the page remains in the browser; reloading the page would lose any locally set javascript variables, and you'd just be loading the default settings as they are coded in the .html page.
Then there's the persistence issue to deal with. Your forums remember the skin the user had on the last visit. At a glance, it looks to me like the doSkin() function (the one in your skin.js file, which is much more extensive than the one you posted) sets a cookie to remember the user's selected skin. OK... you could read that cookie using javascript in your .html pages, and then use that to build the menu.
Sorry for the rambling... just typing as I go, without too much organizing. I guess it boils down to these points:
(1) the skinning capability of the forum is based partly on javascript and partly on asp, working together. If you were to simply rename your .html pages to .asp, then you could apply the skinning functions that the forum uses to your other, non-forumk pages. But...
(2) If you have to use .html instead of .asp for your non-forum pages, then you lose the asp side of the skinning capability, so
(3) you'd have to make up for that loss on the client side, with javascript, which means that
(4) the existing javascript functions (like doSkin() ) won't work as they are, so
(5) those functions will have to be replaced or extensively re-written.
The extent of the re-write would depend on how far you want to carry the skin idea. For example, do you want the user to be able to
select a skin on
any page; forum page as well as
non-forum page. Or do you just want the skin selected on a forum page to persist to non-forum pages, with no opportunity to select a skin on non-forum pages? If a user can select a skin on a non-forum page, do you want that selection to persist across pages? If you want persistence, then should that selection persist across
all pages, including from a forum page to a non-forum page, and vice versa? On a non-forum page, when a user selects a new skin (affecting images only), do you want the page to reload like it does on the forum pages, or do you just want the menu to change without reloading?
I can see ways to do these various things without asp, but it would require a bit of custom javascripting. For example, if a skin has been set on a previous visit, or by using the control on a forum page, you could have a js function that reads the cookie, and applies the skin to the html page using the onLoad event. You could make your own skin selector control (maybe even build it into a menu) for html pages. That control would call your own doSkin()-like function to (a) set the skin, (b) write the selection to the cookie, and (c) reset the menu by either (i) reloading the page or (ii) modifying the menu's internal data (either one is do-able).
Are you ready for a javascript challenge? If so, I can help.
Cheers,
Kevin
P.S. Sorry for the really long post. It's been a while since I waxed long winded.