Customizing Koha 3′s OPAC logo

koha3-opac-logoIn Koha 3, the Koha logo is embedded in the blue search bar which appears on every page. The source for the logo image, as in Koha 2, can be changed via a system preference: opacsmallimage. The difference in Koha 3 is that the display of the logo is much more tightly integrated with the layout of the page, making it a little trickier to embed a custom image. The logo is displayed using an image-replacement technique with the intention of creating more semantic and accessible markup. The HTML consists of an h1 tag and a link:

<h1 id="libraryname">
<a href="/cgi-bin/koha/opac-main.pl">Athens County Public Libraries</a>
</h1>

The CSS for the <h1> tag defines a background image for the element and a fixed width to match the image that will appear in its place:

background:transparent url(../../images/koha-logo.gif) no-repeat scroll 0 50%;
border:0 none;
float:left !important;
margin:0;
padding:0;
width:120px;

The CSS for the <a> tag inside the <h1> hides the link text and sets the container, again, to match the image site:

h1#libraryname a {
border:0 none;
cursor:pointer;
display:block;
height:0 !important;
margin:0;
overflow:hidden;
padding:40px 0 0;
text-decoration:none;
width:120px;
}

Notice that the first padding value matches the height of the koha logo image, and the width value matches the image height.

There’s one more setting that fits together with these to place all these pieces together. One of the containers that fits together to make the search bar is <div id=”fluid”>, a container that holds all the elements to the right of the logo. div#fluid has a left margin that matches the width of the logo:

#fluid {
margin-left: 124px;
margin-top : .4em;
padding-left : 1em;
}

Using a custom logo

Okay, so what does all this mean for the purposes of adding a custom logo? Let’s use as an example a custom logo for the Athens County Public Libraries, 200 pixels x 80 pixels. We’ll put the image on the web somewhere and point the opacsmallimage system pref to that location.  Here are the results:

koha3-acpl-logo1 As you can see, the image is the wrong size for the “container” formed by the CSS. In order to make it fit we have to redefine the container. We’ll do that by entering some CSS into the OPACUserCSS sytem preference:

h1#libraryname {
width:220px;
}
h1#libraryname a {
padding:80px 0 0;
width:220px;
}
#fluid {
margin-left: 224px;
}

Here is the result:

koha3-acpl-logo2

Recommendations

This technique gives you some freedom to customize, but care should be taken when using logos that are very much bigger than the default Koha logo. In the example above, using an image as wide as 220 pixels pushed the width of the search bar contents so wide that the contents wrapped when the browser was resized to 800 x 600 pixels. Best practices will be determined by your audience and their expectations for how your site will appear in their browser.

Tags: , ,

4 Responses to “Customizing Koha 3′s OPAC logo”

  1. Lynn Henry Says:

    I’m not adept at html or java. Wondered if you could help me in customizing my catalog on koha. I’m not sure after reading several of the tutorials how to actually change the source code on the koha server.

  2. oleonard Says:

    Lynn, changing the source code on the server is a much bigger job than I can cover here. If changing the core functionality of Koha is something you require for your library and you don’t have the resources in-house to accomplish it I’d recommend looking into paid support: http://koha-community.org/support/paid-support/

  3. Mike Mason Says:

    Advice for newbies like me who know little about html: The code given above to enter into OPACUserCSS works fine, provided you DON’T include the line numbers in your cut-and-paste as I did! They are not part of the code, and they prevent it working.
    Just above the code are 3 icons. If you click on the left one (a notched page with ) you get the code without line numbers which you can cut and paste.

  4. David Peers Says:

    This blog helped me in narrowing down some problems with the latest release candidate, Why do they always seem to leave out vital documentation when they release a new version? It may be minor to them but not to me. I’m sure we’re not alone.

Leave a Reply


Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported.