Mega-ZBlog

You are here.

Mega-ZBlog header image

Theme Mod

December 9th, 2006 · 1 Comment · Website

I just made a small mod to this theme… now mousing over each of the wallpapers shows a preview, just like in Office 2007.

Here’s how I did it… first of all, a cookie called wp_content stores the number of the wallpaper the user clicked on last, so we can show the same one across page loads. When the page loads, a javascript function called init() changes the background to this stored wallpaper. I added a global variable called mzzt_wall to grab this number for my own purposes later. It will store what the user’s current wallpaper is, even if the user mouses over others to preview them.
Next, I added two functions that I would hook into various mouse actions on the little boxes. mzzt_setbackground assigns mzzt_wall with the number of the wallpaper you click on. mzzt_resetbackground calls an existing changebackground function with mzzt_wall… which loads that wallpaper onto the page.

Then, I went into the PHP source and found the blob that prints out the links used for the boxes. The onclick event calls changebackground to set the current wallpaper… I changed the event to onmouseover, so the wallpaper is changed when you move the mouse over the box. Then, I added an onmouseout event and assigned it mzzt_resetbackground, so when you move the mouse out you get your old wallpaper back. Then I added a new onclick event, and gave it mzzt_setbackground. When you click it, nothing seems to happen, since it just sets mzzt_wall silently. But when you move the mouse out, mzzt_resetbackground grabs that value and uses it as your new wallpaper. 🙂

Only possible quirk is that even when you mouseover your wallpaper cookie is set. Oh well, not too big a deal.

[Edit: Fixed it.  All I needed to do was duplicate their changebackground into mzzt_changebackground without the cookie code, and then, to remove duplicate code, have changebackground call mzzt_changebackground and set the cookie on a separate, new statement.  Easy.]

Tags: ·

1 response so far ↓

  • 1 joey // May 26, 2007 at 1:48 pm

    hi, im not a coder, but do you think you could send me that file? i quite like it!=p nice site, have the same theme =p

You must log in to post a comment.