Day: August 22, 2005

  • Sloganized.

    I probably won’t leave it like this, but I’ve swapped out the random signature picker (that which provides the silly text just below the big site logo, up there) with a random slogan picker. At first I was going to use the Sloganizer, which is awfully cool all by itself, but their code refused to play nice with Monaural Jerk’s template-based system. This merely provided me with incentive. I took some time and learned how to make my own!

    function gdSlogan() {
      $sloganfile = file('/PATH/TO/YOUR/slogans.txt');
      $sloganraw = $sloganfile[rand(0,count($sloganfile))];
      $slogantag = 'XYZ';
      $sloganname = 'YourName';
        $sl1 = '<span class="randquote">';
        $sl1 .= str_replace($slogantag, $sloganname, $sloganraw);
        $sl1 .= '</span>';
      return $sl1;
    }
    

    The “slogans.txt” file consists of a bunch of… er… slogans, with the characters XYZ where one’s name should go. I then have that string replaced with, in my case, “GreyDuck” but you could use anything else you like. (Note: I also have a “span” wrapper to make the text behave accordingly with my particular stylesheet.)

    Why didn’t I just write the slogans file so that my nickname would already be in place? Don’t be silly! How would I learn these little tricks if I didn’t push myself just a little bit? Besides, this means that someone who’s equally-or-less skilled at PHP-fu can take that bit o’ code and, say, my slogans file and plug them into their own site, huh?

    It’s a public service, I tell ya. I’m all about helping others.