PDA

View Full Version : Random Banner/Reply BG


Shpookdefied
02-06-2003, 03:43 AM
I am customizing Mist's Random Banner hack for use in Firefly's Fast Reply. I'm trying to get the textarea background to come up as random BG's, but it doesnt seem to be working. This is what I have in showthread.php:

//Define Variables //
$qrback[1]="qrback1.jpg";
$qrback[2]="qrback2.jpg";
$qrback[3]="qrback3.jpg";
$qrback[4]="qrback4.jpg";
$numbgs = count($qrback);

// Generate randomness
$num = rand(1,$numbgs);

//output background
$qrback = "{imagesfolders}/qrback$num";

And this is in the showthread_replybox template:

<textarea name="message" rows="9" cols="$textareacols" wrap="virtual" tabindex="1" style="background-image: url('$qrback');
background-repeat: no-repeat; background-attachment: fixed"></textarea>

I have also tried this in showthread.php:

//output background
$qrback = "<textarea name="message" rows="9" cols="$textareacols" wrap="virtual" tabindex="1"
style="background-image: url('qrback$num); background-repeat: no-repeat; background-attachment: fixed"></textarea>";

And this in showthread_replybox:

<td>$qrback><br><smallfont><a href="javascript:checklength(document.vbform);">[check message length]</a></smallfont></td>

I'm not very good with PHP, so I have no clue why it's not working. Can anyone help?

And btw, I am not and will not take credit for this if/when I get it to work. Mist can release it as his own if he wishes.

Shpookdefied
02-06-2003, 06:30 PM
BTW, In showthread.php, I've placed the code underneath this:

eval("\$replybox = \"".gettemplate('showthread_replybox')."\";");
}

mr e
02-06-2003, 09:18 PM
dont you need ".jpg" on the end? also you could do it like this


// Generate randomness
$num = rand(1,4); //make max number the number of images you have

//output background
$qrback = "{imagesfolders}/qrback$num.jpg";

Shpookdefied
02-06-2003, 10:49 PM
Well, from my understand, the file is defined here:

$qrback[1]="qrback1.jpg";

so qrback$num would define the $qrback call as qrback1.jpg

Also,
$num = rand(1,4);
is doing the same thing as
$numbgs = count($qrback);

// Generate randomness
$num = rand(1,$numbgs);
But in the bottom example, it just counts the number of variables and applies the randomization to that. Just about the same thing, except you don't have to set the rand max number when adding a new variable. :D

So I've tried a few different things, still to no avail. But I WILL have this working before I put my board up :D

mr e
02-07-2003, 12:03 AM
i know i have to set the max number, but i dont have to type each file in, that part doesn't matter, if you want to do it your way do this


//Define Variables //
$qrback[1]="qrback1.jpg";
$qrback[2]="qrback2.jpg";
$qrback[3]="qrback3.jpg";
$qrback[4]="qrback4.jpg";
$numbgs = count($qrback);

// Generate randomness
$num = rand(1,$numbgs);

//output background
$qrback = "{imagesfolders}/$qrback[$num]";


most of this is just repetitive, you could just randomize the number, your way only REALLY matters if they were named for ex: boat.jpg, plane.gif, since then you'd have to define the names somehow, you have all the names "qrback#.jpg" so my way would be faster

Shpookdefied
02-07-2003, 03:33 AM
Okay, I see what your saying now. I misunderstood you at first. Let me go give this a try, and I'll come back with the results.

Shpookdefied
02-07-2003, 09:05 PM
Okay, well I've tried, still nothing. I'm not getting any errors, but the BG just isnt showing up. Help?

mr e
02-08-2003, 04:41 AM
are you sure the html for the bg is correct?

try this for the code in showthread.php

above this

eval("dooutput(\"".gettemplate("showpost")."\");");


put this

// Generate randomness
$num = rand(1,4); //make max number the number of images you have

//output background
$qrback = "{imagesfolders}/qrback$num.jpg";


haven't tested it, but try that and make sure the html is correct

Shpookdefied
02-08-2003, 04:13 PM
Above? Hmmm, I assumed below.:D Okay, I'll go give it a shot.

Dpcows
02-14-2003, 08:44 PM
Originally posted by Shpookdefied

//Define Variables //
$qrback[1]="qrback1.jpg";
$qrback[2]="qrback2.jpg";
$qrback[3]="qrback3.jpg";
$qrback[4]="qrback4.jpg";
$numbgs = count($qrback);

// Generate randomness
$num = rand(1,$numbgs);

//output background
$qrback = "{imagesfolders}/qrback$num";


i think you need to look at your arrays.
the way you make then is good, but displaying it isn't it.

your doing this: qrback$num
this will generate: qrback1 or qrback2 and increase the numbers to the max you have set. your just telling it to show $num with qrback before it.

not showing anything from the array

to do the array correclty: $array_name[$value].
so for you it would be: $qrback[$num].
that would show them

hope this helps