sofiaviolet: Livejournal - I'm just here for the free porn (porn on the livejournal)
Sofia Violet Emilie Blackthorne ([personal profile] sofiaviolet) wrote2007-10-03 10:17 pm

TUTORIAL: Random text/images.

Disclaimer: I only know that this works in the Boxer. I can try to help you adapt it to other layouts, but no guarantees because this is the only one I am familiar with.

Please note that this is not a tutorial for random background images; check [livejournal.com profile] s2howto for that. Their tutorial for random background images is where I got most of the code for this.

FOR TEXT:

1. Create a new theme layer, or edit an existing one. You'll need to paste in the stuff that goes with function Page::print() if you don't already have it in the layer. (Comment and I will try and track it down for your layout, or check [livejournal.com profile] s2howto.)

2. Directly under fuction Page::print() {, paste:
var string[] backgroundurl;
$backgroundurl[0] = "whatever";
$backgroundurl[1] = "other whatever";
var int randomurl;
$randomurl = rand(0, ((size $backgroundurl) - 1));

You can add as many lines as you want (I have 34 at the time I'm writing this), just make sure to put a semicolon after each line.

3. Figure out where you want your random text to show up. I put mine between the title and the link to my userinfo, so I'll use that in my example.
<div class="title">$title</div>
$backgroundurl[$randomurl]
<div><a href="$*SITEROOT/userinfo.bml?user=$.journal.username" class="subtitle">$.journal.name</a></div>


4. Save and compile. If it gives you an error, mess around with it, or copy everything into a text file and send it to sofiaviolet@sofiaviolet.com and I will attempt to provide help.

5. ...

6. PROFIT!

***

FOR IMAGES:

1. Create a new theme layer, or edit an existing one. You'll need to paste in the stuff that goes with function Page::print() if you don't already have it in the layer. (Comment and I will try and track it down for your layout, or check [livejournal.com profile] s2howto.)

2. Directly under fuction Page::print() {, paste:
var string[] backgroundurl;
$backgroundurl[0] = "http://blah.com/picture1.jpg";
$backgroundurl[1] = "http://blah.com/picture2.jpg";
var int randomurl;
$randomurl = rand(0, ((size $backgroundurl) - 1));

You can add as many lines as you want (I have 34 at the time I'm writing this), just make sure to put a semicolon after each line.

3. Figure out where you want your random image to show up. I put mine between the title and the link to my userinfo, so I'll use that in my example.
<div class="title">$title</div>
<img src="$backgroundurl[$randomurl]">
<div><a href="$*SITEROOT/userinfo.bml?user=$.journal.username" class="subtitle">$.journal.name</a></div>


4. Save and compile. If it gives you an error, mess with it, or copy everything into a text file and send it to sofiaviolet@sofiaviolet.com and I will attempt to provide help.

5. ...

6. PROFIT!

If anyone reading this actually knows what they're doing and has clarifications/corrections for these directions, I bow before your superior knowledge; please comment.