Note: This is the roundabout way to go about things, so bare with me! This will create a series of up to 5 randomized header images for your journal, as requested earlier.
You must have a paid account in order to accomplish this; this can actually be used on any layout, to my knowledge, but seen here using The Boxer.
This is really simple, but requires quite a few steps. If you follow everything exactly, you should be fine. First, I'll show you the code & explain a few things, and then let you know how to use it. Capiche? Then let's go.
Randomized Header Image Code
#############################################
#
# Print Randomized Header Image
# ==Modified by Illgoest.LJ.com==
#
#############################################
function print_random_header() {
var string[] headerurl;
$headerurl[0] = "
http://www.yourhost.com/yourheader1.jpg";
$headerurl[1] = "
http://www.yourhost.com/yourheader2.jpg";
$headerurl[2] = "
http://www.yourhost.com/yourheader3.jpg";
$headerurl[3] = "
http://www.yourhost.com/yourheader4.jpg";
$headerurl[4] = "
http://www.yourhost.com/yourheader5.jpg";
var int randomurl;
$randomurl = rand(0, ((size $headerurl) - 1));
"
";
}
1) THE CODE: The above is the code that generates the functions needed to process which headers you'll be using. You can add as many headers as you like, really, following the $headerurl[0] = "
http://www.yourhost.com/yourheader1.jpg";
if you like, however, we won't get into that yet. the $headerurl[0] determines which header URL to get, and the link is the link to your image. The "
";
determines what the print_random_header(); function does later on.
2) SETTING IT UP: This is where it gets a little tricky. In the
Advanced Customization center you'll want to create a new Top-Level layer. When you edit the code, add in this:
layerinfo "type" = "layout";
layerinfo "name" = "Random Header Layout";
and hit "compile". Your layer should be named in the
Your Layers page now, and click "edit". Here's where it's going to get a bit confusing. Though the
s2howto journal says that you don't have to do this, well, you don't. But, if you run into gliches when trying to compile your code - say, for instance, you take information from your theme layer and put it here, you're going to want to do this.
Go to the
Boxer source code, copy & paste this into your new layout layer. Your layout should be the Boxer now, and you can add a theme here later (more on that in a minute). Now, copy & paste the code above your Page::print_bodies(); function.
In order to get the headers to actually print, you're going to have to paste in the print_custom_head() function ( """; print_random_header(); """) where you want your header, in my case, I have it in the Print & Print Bodies section, rather than the head - though I'm sure the old tutorial would work just fine. In your print bodies, you will insert the line of code here - I'm only showing a snippet because it would be too confusing otherwise. Here is an exmaple of where you can place it:
#############################################
#
# Print and Print Bodies
#
#############################################
function Page::print() {
var string title = $this->title();
"""
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
""";
$this->print_head();
"""
$title
""";
print_nav($this);
"""
""";
print_random_header();
"""
$title
$.journal.name You need EVERYTHING in the grey area beneath the "RANDOMIZED HEADER" such for this to work. If you forget """ or """;, your layout layer will have errors because of broken strings, and you will have headaches.
But see- that's all there is to it! Now to the fun part, setting up a new theme layer.
3) USING A THEME LAYER: Now that you've got this new layout working, you're probably wondering what happened to your old theme layer & why it won't show up. Go to the
Your Layers page. If you've already got a theme layer, open up the preexisting theme layer & copy & paste the codes into a text file. You'll need it in a few minutes. Then, go back to the layers page.
From the "Create layout-specific layer" drop down menu, select "theme" and for the Layout, whatever you named your Randomized Header Layout, after the usual paid account styles. Once the them layer has been created, edit it & compile. Almost done.
Now go back to the
Customization Page. Make sure your Random Header Layout is selected in the Layout step. Hit "Change", just to make sure. Now, your new theme layer should appear under "Themes", in the next step. Select it from the drop-down menu, hit "Change", and you're done!
You can see the randomness in action at
unamused_icons, just don't mind the ugliness of the layout or the lack of links. Refresh to get a new header every time. Let me know how it works (or doesn't work) for you!