Randomize the portal logo

by paulbhartzog — last modified Dec 30, 2008 03:01 PM
This HowTo describes how to randomly load different logos in place of the default Plone logo.
  1. Copy this from plone.css into your ploneCustom.css
    #portal-logo {
        background: url(&dtml-portal_url;/&dtml-logoName;) no-repeat;
        border: 0;
        margin: 0.75em 0em 0.75em 1.5em;
        padding: 0;
    }
    
  2. Create this Python script in your custom folder (I named it "logo").
    from random import choice
    # logos folder
    logos_folder = "logos"
    # logo names go here
    all_logos = ['logo1.jpg', 'logo2.jpg', 'logo3.jpg']
    # grab a random one
    logo = choice(all_logos)
    return logos_folder + "/" + logo
    
  3. change this line:
        background: url(&dtml-portal_url;/&dtml-logoName;) no-repeat;
    
    into this line:
        background: url(&dtml-portal_url;/&dtml-logo;) no-repeat;
    
  4. Do NOT mess with this part of plone.css:
    #portal-logo a {
    display: block;
    text-decoration: none;
    overflow: hidden;
    border: 0;
    margin: 0;
    padding: 0;
    padding-top: <dtml-var "_[logoName].height">px;
    height: 0px !important;
    height /**/: <dtml-var "_[logoName].height">px;
    width: <dtml-var "_[logoName].width">px;
    cursor: pointer;
    }
    
  5. For my site my logos are larger than the normal plone logo so I had to add in the following lines to my #portal-logo section in ploneCustom.css:
        width: 329 px;
        height: 79 px;
        padding-bottom: 20px;
    

Thx to: Robert Hunter, and Chandrakantha Nagaraja

Have fun and if anyone knows why #4 messes everything up, please let me know.

-Paul