Delete skin preference in MT

First and foremost, 1000 thank you's to Jennifer for helping me work out this code. I never could have gotten this done without you. You truly are a goddess!

I presented Jennifer with a question: How do I remove skins in Movable Type? or –to be more specific– How do I let users delete their skin preferences?

Jennifer coded away and came up with an entirely new cookie script that worked great. If a user requested, it would reassign the skin preference to the current "default" skin. Ultimately, this created one more administrative step than I already had – assigning a "default" skin within this script. So, I was hesitant to go that direction.

I explained to Jen that the default behavior is not to assign a skin at all, and then present the "default" skin to the user for that session. No cookies, no nothing. Once the user picks a skin, they accept a cookie that identifies their skin preference and that skin is shown upon every visit to the page. The user can change their skin preference, but they cannot "unring the bell" and go back to seeing whatever "default" skin I would have them see. (ie. During Christmas, I had a holiday skin as the default instead of the Buffett-esque skin)

I asked if there was a simple way to delete the user's cookie, and the following lines were born. If you want to use this in your MT, please feel free. I skin my site based on the examples provided by Brenna. Amy also has some information here and there is always good info at Girlie's site.

In order to delete the cookie, the user has to request the page that deletes the cookie. On my site, that page is http://blog.kevindonahue.com/skins/reset.php. So a link that looks like this:

<a href="reset.php">reset skins</a>

connects to a page that deletes the cookie called "skin" using this php:

&lt?php
setcookie('skin',$newskin,time(),'/');
setcookie('skin',$newskin,time(),'/','.your-domain-name.com');
?>

Notes: The PHP must be placed above the <HEAD> tag. I think mine appears before everything. The name of the cookie ('skin') must be the same as the cookie you are setting on when the user selects their skin preference. For me, that takes place on a page called "testskin.php".

Again, this is the solution that works for me. I would really like for other sites to consider implementing this concept, as it would save me the trouble of deleting their cookies periodically to see what skin their currently featuring. I'm not much help for configuring it to work for you, but I'll help as best I can.

Again, muchos gracias to the incredible Jen.

Share on FacebookTweet about this on TwitterShare on LinkedInEmail this to someone

One thought on “Delete skin preference in MT”

Comments are closed.