elfgirl: (dreamwidth)
elfgirl ([personal profile] elfgirl) wrote in [community profile] getting_started2009-05-04 10:17 am

Rotating Headers in Transmogrified?

I know that Transmorgrified allows headers, but does anyone know if it's possible to set custom CSS up for rotating headers (display a randomly selected header from a set group of available headers)? I've seen folks on LJ with their styles set up to do this and I do it myself in my WP journal, but I've no idea how to do it with custom CSS here.

Thanks!


Sorted! From the instructions found here:

NOTE: This solution is only workable with custom theme layers, which means you have to have some sort of paid account. It may or may not work with the other S2 DW themes. (ETA: it also works with Negatives.)



1. Create a custom theme layer by going to Organize > Select style > Developer Area > Your Layers and selecting Create layout-specific layer, type: theme, layout: transmogrified

2. Add the following code to your theme layer:

function Page::print_custom_head()
{
var string[] header_image;
var int header_index=0;

$header_image[$header_index++] = "http://www.imageaddy.com/header_1.jpg";

$header_image[$header_index++] = "http://www.imageaddy.com/header_2.jpg";

$header_image[$header_index++] = "http://www.imageaddy.com/header_3.jpg";

var string header_url = $header_image[rand($header_index) - 1];

    """
    <style type="text/css">   

#header {
    background-image: url("$header_url"); /* Header image URL */
    height: 140px;
    background-scroll: no-scroll;
    background-repeat: no-repeat;
    background-position: center;

}

#header h1 {
    display: none;
}

#header h2 {
    display: none;
}


     </style>
     """;
}


Replace the "http://www.imageaddy.com/header_1.jpg" with the URL of whatever images you'd like to use for your rotating headers. Change the height under the #header CSS code to whatever the height of your header is.

3. Click the Compile and Save button in the top left corner.

4. Go to Organize > Select journal style > Your custom layers and choose the custom Transmogrified layer.
htbthomas: (O Rly? VG)

[personal profile] htbthomas 2009-05-04 02:24 pm (UTC)(link)
Transmogrified allows headers? Do you know a link for the CSS for that?

And I second wanting to know how to do a rotating header. :)
htbthomas: (htbthomas awesome)

[personal profile] htbthomas 2009-05-04 04:06 pm (UTC)(link)
Thanks so much!
matgb: Artwork of 19th century upper class anarchist, text: MatGB (Default)

[personal profile] matgb 2009-05-04 04:14 pm (UTC)(link)
CSS 101: Everything can have a background image
CSS 102: Most things look better without one

;-)
matgb: Artwork of 19th century upper class anarchist, text: MatGB (Default)

[personal profile] matgb 2009-05-04 05:10 pm (UTC)(link)
So you put a background image to the Header section and define a height with CSS. Negatives (which you're using) has a #header defined, and I know Transmogrified does, so simple trick of aligning it into the right bit.

This should work:

#header {
background-position: center bottom;
background-repeat: no-repeat;
background-image: url(http://taktix.org/images/header-tlrt.jpg);
min-height:100px;
}

Replace your image with mine and change the height to suit, obviously.

No idea how to rotate it though, sorry.
adalger: Earthrise as seen from the moon, captured on camera by the crew of Apollo 16 (Default)

[personal profile] adalger 2009-05-04 05:36 pm (UTC)(link)
Well, here's the thing. CSS doesn't really have any logic operators, or random number generators. If you want to have a randomly selected header, that has to happen in something like javascript or a custom layout layer.
matgb: Artwork of 19th century upper class anarchist, text: MatGB (Default)

[personal profile] matgb 2009-05-04 09:28 pm (UTC)(link)
That's actually rather cool. Not sure I'll use it, but the fact that you can is useful.
htbthomas: (Wink HIMYM)

[personal profile] htbthomas 2009-05-04 08:31 pm (UTC)(link)
I'm partial to my header image-based journals. *stubborn* ;)
matgb: Artwork of 19th century upper class anarchist, text: MatGB (xBatshit)

[personal profile] matgb 2009-05-04 09:20 pm (UTC)(link)
[personal profile] miss_s_b is rather partial to her vinyl record collection, but at least she has a point on quality there. *web evolution* ;-)
htbthomas: (ohnoes! Jimmy SR)

[personal profile] htbthomas 2009-05-04 09:33 pm (UTC)(link)
Well, I know what I have at my DW now is clunky and unstylish... Sort of why I wanted the CSS for doing something nicer with a header in Core 2...

*cowers in corner* ;)