Whenever I add a custom logo to a client’s Moodle theme, I always try to leave the H1 tag and title in the HTML for search engines and screen readers to find. And, since this isn’t the method described in the Moodle Documentation, I thought it was time I shared my method in the name of accessibility and SEO.
Here’s what I’m talking about. What follows was pulled from header.html in the Standard theme folder.
<div id="header-home" class="clearfix">
<h1 class="headermain"><?php echo $heading ?></h1>
<div class="headermenu"><?php echo $menu ?></div>
</div>
All code in this tutorial is presented in green on a black background. Highlighted text will appear in yellow; additions will appear in blue; subtractions will appear in red with a line through the text.
- The first thing you’ll want to do is copy your logo to your theme’s “pix” folder. For example, since I’m using the Standard theme, I would copy my logo to …/moodle/theme/standard/pix/.
- Then, open your theme’s header.html file and search for the following:
<h1 class="headermain"><?php echo $heading ?></h1>
<div class="headermenu"><?php echo $menu ?></div>
This should appear twice:
- <div id="header-home" class="clearfix">
<h1 class="headermain"><?php echo $heading ?></h1>
<div class="headermenu"><?php echo $menu ?></div>
</div>
and:
- <div id="header" class="clearfix">
<h1 class="headermain"><?php echo $heading ?></h1>
<div class="headermenu"><?php echo $menu ?></div>
</div>
The first appearance (header-home) determines what will appear on your front page only. The second appearance (header) determines what will appear on all other pages. If you want your logo to appear on ALL pages, you will simply have to add it twice, in both places.
- Add your logo between h1.headermain and div.headermenu using PHP to designate a relative path to your logo.
<h1 class="headermain"><?php echo $heading ?></h1>
<img src="<?php echo $CFG->themewww .’/’. current_theme() ?>/pix/logo.jpg" />
<div class="headermenu"><?php echo $menu ?></div>
- Add a “logo” class to your image for future positioning.
<h1 class="headermain"><?php echo $heading ?></h1>
<img class=”logo” src="<?php echo $CFG->themewww .’/’. current_theme() ?>/pix/logo.jpg" />
<div class="headermenu"><?php echo $menu ?></div>
- Save changes and check your theme to make sure you have entered everything correctly. Your header should look something like this, with both your site title AND logo showing:
Now that we have your HTML in order, let’s hide your site title from view without actually “getting rid” of it. We’ll do this using CSS.
- Open your primary CSS document. If you are using the Standard theme, use styles_layout.css. If you are using a NewSchool Learning theme, use styles_base.css, styles_default.css, or styles_themename.css (where themename is the name of the theme you’re using!).
- If you are only adding a logo to the front of your site, add the following to the very bottom of the CSS document opened above.
#header-home .headermain {
position:absolute;
left:-9999px;
}
#header-home .logo {
float:left;
}
- And, if you are adding a logo to all pages (and you have made the appropriate additions to header.html noted above), your addition will look like this:
#header-home .headermain,
#header .headermain {
position:absolute;
left:-9999px;
}
#header-home .logo,
#header .logo {
float:left;
}
- Save changes and check your site. It should look something like this:
If you find that your logo isn’t centering properly, you can always add padding to your image until you get it placed where you like.
header-home .logo {
float:left;
padding:Wpx Xpx Ypx Zpx;
}
In the above example W=”top”, X=”right”, Y=”bottom”, and Z=”left”.
We will be taking proposals for custom work between now and the end of December. Time is limited, but we would like one or two new projects to be completed for the first week of January. Contact us if you have a project you think we’d be interested in.
I spent the majority of this rainy Sunday coding what will become NewSchool Learning’s seventh Premium Theme - Prestige is a 900px, fixed-width, TWO-COLUMN Moodle theme that will come in as many color combinations as I can think up.
The choice of using the two-column feature is, of course, up to the admin installing the theme, as I’ve included a single-line edit to turn it off. And, then, there is another single-line edit if you prefer something a little wider or thinner than 900px. The theme stays intact at any width.
Back in September, we were commissioned to do a custom Moodle theme for our friends at Liip (Moodle Parther in Switzerland). They wanted a corporate theme that matched their current website so we gave them what they asked for. The cool thing about this theme is that Liip has offered their theme to the Moodle community for free!
It’s a complete one off.
- 900px fixed-width
- Crisp white background
- Subdued black type spaced with care
- Grayscale icon set
- Icons on block headers
- Clean, browser tested, validated goodness!
You can demo this theme on our Moodle Demo server.
To download this new theme, click here and click “Liip.”
Enjoy.
Back in August, I wrote that we would try updating our collection of themes at least once per month. In the spirit of keeping that pace, I’m pleased to offer our sixth premium theme - Stealth.
While I don’t think that a black Moodle theme is exactly what everyone is looking for, I thought it was important that it was at least an option for that one person who might be looking for it.
The biggest challenge of this theme was the icon set, which had to be redone to work with the black background. The overall effect is a very clean, sophisticated, and dark theme for Moodle.
You can see it for yourself here.
After a few hours of making things fit, it looks like we’re ready to start blogging on WordPress. Visit frequently to read about our adventures in Moodling!