Log in

No account? Create an account

Previous Entry | Next Entry

random header image script

  • Apr. 5th, 2007 at 12:30 AM
I know that somewhere I saw a tutorial and a working example on how to implement a random header image script for Expressive. I've looked through every entry here and I can't find it. If someone has seen it in another community or knows what I'm talking about, I'd love to get a link or the code.

Just to elaborate, it does the same thing as the "random text" or "random user pic" script that I have seen somewhere in this community, except it does it with the header image.


( 12 comments — Leave a comment )
Apr. 5th, 2007 07:39 am (UTC)
Provided you don't care about doing horrible things as far as coding standards are concerned, you can use the random quote code I pinched from Component ages back and tweak it to randomise the header. This will mean tooling around with the user layer.

function Page::lay_print_header_links() {

    # random subtitle script [replaces header.png - should be in head, but needs to be after base stylesheets not before]
	var string[] banner;

  		$banner[0]="""background-image: url(http://www.livejournal.com/header01.png);""";
  		$banner[1]="""background-image: url(http://www.livejournal.com/header02.png);""";
  		$banner[2]="""background-image: url(http://www.livejournal.com/header03.png);""";
  		$banner[3]="""background-image: url(http://www.livejournal.com/header04.png);""";
  		$banner[4]="""background-image: url(http://www.livejournal.com/header05.gif);""";
  		$banner[5]="""background-image: url(http://www.livejournal.com/header06.jpg);""";

    		var int random_banner;
    		$random_banner = rand(0, ((size $banner) - 1));

    # where random banner lives
    """<style type="text/css">#header {$banner[$random_banner]}</style>""";

    # Menu start
    """<div id="message-window" class="hidden"></div>\n""";
    """<div id="header-photo">\n<div id="header-photo-inner"></div>\n</div>\n""";
    """<div id="header-text"><ul class="nav">\n""";

    # Standard Journal Pages (Recent, Archive, Friends, Userinfo)
    foreach var string v ($.views_order) {
        var string url   = $.view_url{$v};
        var string text  = lang_viewname($v);
        var string class = "item";
        if($v == $.view) {
            $class = $class + " current";
        if($v == $.views_order[0]) {
            $class = $class + " first";

        $class = " class=\"$class\"";

        print """<li$class><a href="$url" title="$text">$text</a></li>""";

    var Link memories_url = $.journal->get_link("memories");

    # Memories
    if($memories_url.url != "") {
        println safe """<li class="item"><a href="$memories_url.url" title="$*text_view_memories">$*text_view_memories</a></li>""";

    # Menu end
    <div id="header-name">""";
    var string base_url = $.journal->base_url();
    var string friends_url = $.view_url{"friends"};
    if ($this isa FriendsPage) {
        print safe """<a href="$friends_url">""" + $this->view_title() + """</a>""";
    } else {
        print safe """<a href="$base_url">$.global_title</a>""";

    if(not $this isa FriendsPage) {
        print safe """
      <div id="header-description">$.global_subtitle</div>""";

    </div><span id="header-content-decor" class="decor"><b></b><u></u><s></s><i></i></span></div><!-- End Header Content -->
    </div><span id="header-decor" class="decor"><b></b><u></u><s></s><i></i></span></div><!-- End Header -->""";
Apr. 5th, 2007 12:36 pm (UTC)
<STYLE> tags are not allowed in the <BODY> element, so will this even work? I think the random part would have to go into Page::print() instead.
Apr. 5th, 2007 08:59 pm (UTC)
styles tags are not supposed to go in the body, but they do work. I'm using this lump of code to randomly swap headers without a problem. That's why I mentioned that it's bad coding practice.

the problem I had with it was that the style change needs to go after the linked stylesheets. all other solutions I tried placed it before, so it was overwritten by the standard style.

I didn't try
, but it might be a more elegant solution.
Apr. 5th, 2007 09:29 pm (UTC)
The uglier the better. ;P

I haven't had time to implement it but when I do, I'll let you know how it goes.
Apr. 6th, 2007 12:23 am (UTC)
Didn't Work
I can't figure out what isn't working, but Landscape Desert Day puts things in wonky places. =/
Apr. 6th, 2007 08:16 am (UTC)
Re: Didn't Work
I can't see your layer code, but looking at the HTML on your LJ, the style element is not displaying. Even if the random script wasn't working, that style element should be in place before the HTML that creates the header.

I'd need to see your layer code to do more than guess.
Apr. 6th, 2007 03:15 pm (UTC)
Re: Didn't Work
Oh I took everything out. Don't worry about it. It's not a big deal. I kinda give up on this for now. I have a lot more important things going on that are taking up all of my time.
Apr. 5th, 2007 12:51 pm (UTC)
Also, I don't know of any tutorial for Expressive that does a random header image (at least, not one I've written ;). I've seen ones for Smooth Sailing, Component, and this particularly interesting take, which uses a remotely hosted PHP script to randomize headers and will supposedly work with any layout.
Apr. 5th, 2007 03:15 pm (UTC)
Yeah, I know you didn't write it, but I swear I saw one someplace. The example had all the Mixit and some of the Expressive headers in it. Everytime you refreshed the image would change. It was nifty but the link vanished into a blackhole.
Apr. 5th, 2007 05:44 pm (UTC)
O.o Interesting... I've never come across that in any of the style communities. If you by chance happen to find it again, please share it!
Apr. 5th, 2007 09:27 pm (UTC)
Oh I'll definately share it if I find it again.
(Deleted comment)
Oct. 19th, 2007 03:50 pm (UTC)
Nope. I kinda gave up on it. It was so long ago.
( 12 comments — Leave a comment )

Latest Month

March 2016

S2 Help Communities


Powered by LiveJournal.com
Designed by chasethestars