4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Remplois on April 18, 2005, 03:18:43 AM
-
Hi all,
Ive been currently trying to add some cool additions to 4images gallery. My recent attempt is to try and make the banner at the top change whenever you refresh the page, but without success.
So i was wondering whether you could help.
Im using a custom template not the default, im editing the top.html
Now heres the tricky bit, the random image code is in PHP, so ive inserte the PHP coding into a table in the space of the exsisting top_01.gif
But, just to test it, i implemented the new code, and the banner did not change, or have a X in the space where it is. So now ive been pondering over it for a while. Where does the 4images grab the top_01.gif from? as it appears to still be there, even when ive removed it, and removed the images.
I know im inserting PHP into a .html file, although even still, if it was located in top.html, then it would no longer appear on the index?!
Ive added the code to see if you can help me out.
my gallery is located here www.remplois.info/gallery
(please ignore the picture on the banner, its just a joke :p)
Thanks.
{header}
<table width="720" border="0" align="center" bordercolor="#CCCCCC" class="wholetable">
<tr>
<td><TABLE WIDTH=720 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
<TR>
<TD COLSPAN=2> <table width="290" height="80" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
'=================================
' Heres the random image header
'=================================
<?
# selects a random number between 1&4
srand( microtime() * 1000000);
$var = rand(1,2);
# takes the selected number and assigns the location to the image
# to the variable $logo.
switch($var)
{
case 1: $logo="/pics/top_02.gif"; break;
case 2: $logo="/pics/top_01.gif"; break;
}
# creates an HTML image tag in a string and then displays
$display = " <img src=$logo></img> ";
echo ($display);
?>
'=================================
' Heres the end of the random image header
'=================================
</td>
</tr>
</table></TD>
<TD COLSPAN=3 align="right" valign="bottom">
<form method="post" action="{url_search}">
<table border="0" cellspacing="0" cellpadding="1">
<tr>
<td> <input type="text" name="search_keywords2" size="15" class="searchinput" />
</td>
<td> <input type="submit" value="{lang_search}" class="button" name="submit2" />
</td>
</tr>
<tr valign="top">
<td colspan="2"><a href="{url_search}" class="smalltext">{lang_advanced_search}</a></td>
</tr>
</table>
</form>
<td width="207" align="right"> </td>
</TR>
<TR>
<TD COLSPAN=5> <IMG SRC="{template_url}/images/top_03.gif" WIDTH=720 HEIGHT=10 ALT=""></TD>
</TR>
<TR>
<TD> <IMG SRC="{template_url}/images/top_04.gif" WIDTH=20 HEIGHT=30 ALT=""></TD>
<TD COLSPAN=2 background="{template_url}/images/barbg.gif" class="whitetext">{clickstream}
</TD>
<TD> <IMG SRC="{template_url}/images/top_06.gif" WIDTH=10 HEIGHT=30 ALT=""></TD>
<TD background="{template_url}/images/barbg.gif" class="whitetext"><a href="{url_top_images}"><strong>{lang_top_images}</strong></a>
<strong><a href="{url_new_images}">{lang_new_images}</a> </strong></TD>
</TR>
<TR>
<TD> <IMG SRC="{template_url}/images/spacer.gif" WIDTH=20 HEIGHT=1 ALT=""></TD>
<TD> <IMG SRC="{template_url}/images/spacer.gif" WIDTH=270 HEIGHT=1 ALT=""></TD>
<TD> <IMG SRC="{template_url}/images/spacer.gif" WIDTH=170 HEIGHT=1 ALT=""></TD>
<TD> <IMG SRC="{template_url}/images/spacer.gif" WIDTH=10 HEIGHT=1 ALT=""></TD>
<TD> <IMG SRC="{template_url}/images/spacer.gif" WIDTH=250 HEIGHT=1 ALT=""></TD>
</TR>
</TABLE>
<TABLE WIDTH=720 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
<TR>
<TD COLSPAN=3><table width="100%" border="0">
<tr>
<td width="28%" valign="top" class="tablebdr">
<table width="190" border="0">
<tr>
<td><TABLE WIDTH=190 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
<TR>
<TD width="20" height="30"> <IMG SRC="{template_url}/images/mid_06.gif" WIDTH=20 HEIGHT=30 ALT=""></TD>
<TD width="170" height="30" background="{template_url}/images/barbg.gif" class="whitetext">{lang_registered_user}
</TD>
</TR>
<TR>
<TD COLSPAN=2> </TD>
</TR>
<TR>
<TD COLSPAN=2><div align="center">{user_box} <br>
{if random_image} </div></TD>
</TR>
<TR>
<TD width="20" height="30"> <IMG SRC="{template_url}/images/mid_09.gif" WIDTH=20 HEIGHT=30 ALT=""></TD>
<TD width="170" height="30" background="{template_url}/images/barbg.gif" class="whitetext">{lang_random_image}
</TD>
</TR>
<TR>
<TD COLSPAN=2><div align="center">{random_image}</div></TD>
</TR>
<TR>
<TD COLSPAN=2><div align="center">{endif random_image}
</div></TD>
</TR>
</TABLE></td>
</tr>
</table></td>
<td width="95%" valign="top" class="tablebdr"> <p> </p>
<p><br />
<span class="title">{lang_top_images}</span> </p>
<hr size="1" /> <table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td class="bordercolor"> <table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td class="head1" valign="top" colspan="5"> {lang_top_image_rating}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>1</b></td>
<td valign="top" class="row1">{image_rating_1}</td>
<td valign="top" class="row1">{image_rating_user_1}</td>
<td valign="top" class="row1">{image_rating_cat_1}</td>
<td valign="top" class="row1" nowrap>{image_rating_number_1}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>2</b></td>
<td valign="top" class="row2">{image_rating_2}</td>
<td valign="top" class="row2">{image_rating_user_2}</td>
<td valign="top" class="row2">{image_rating_cat_2}</td>
<td valign="top" class="row2" nowrap>{image_rating_number_2}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>3</b></td>
<td valign="top" class="row1">{image_rating_3}</td>
<td valign="top" class="row1">{image_rating_user_3}</td>
<td valign="top" class="row1">{image_rating_cat_3}</td>
<td valign="top" class="row1" nowrap>{image_rating_number_3}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>4</b></td>
<td valign="top" class="row2">{image_rating_4}</td>
<td valign="top" class="row2">{image_rating_user_4}</td>
<td valign="top" class="row2">{image_rating_cat_4}</td>
<td valign="top" class="row2" nowrap>{image_rating_number_4}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>5</b></td>
<td valign="top" class="row1">{image_rating_5}</td>
<td valign="top" class="row1">{image_rating_user_5}</td>
<td valign="top" class="row1">{image_rating_cat_5}</td>
<td valign="top" class="row1" nowrap>{image_rating_number_5}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>6</b></td>
<td valign="top" class="row2">{image_rating_6}</td>
<td valign="top" class="row2">{image_rating_user_6}</td>
<td valign="top" class="row2">{image_rating_cat_6}</td>
<td valign="top" class="row2" nowrap>{image_rating_number_6}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>7</b></td>
<td valign="top" class="row1">{image_rating_7}</td>
<td valign="top" class="row1">{image_rating_user_7}</td>
<td valign="top" class="row1">{image_rating_cat_7}</td>
<td valign="top" class="row1" nowrap>{image_rating_number_7}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>8</b></td>
<td valign="top" class="row2">{image_rating_8}</td>
<td valign="top" class="row2">{image_rating_user_8}</td>
<td valign="top" class="row2">{image_rating_cat_8}</td>
<td valign="top" class="row2" nowrap>{image_rating_number_8}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>9</b></td>
<td valign="top" class="row1">{image_rating_9}</td>
<td valign="top" class="row1">{image_rating_user_9}</td>
<td valign="top" class="row1">{image_rating_cat_9}</td>
<td valign="top" class="row1" nowrap>{image_rating_number_9}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>10</b></td>
<td valign="top" class="row2">{image_rating_10}</td>
<td valign="top" class="row2">{image_rating_user_10}</td>
<td valign="top" class="row2">{image_rating_cat_10}</td>
<td valign="top" class="row2" nowrap>{image_rating_number_10}</td>
</tr>
<tr>
<td class="head1" valign="top" colspan="5"> {lang_top_image_votes}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>1</b></td>
<td valign="top" class="row1">{image_votes_1}</td>
<td valign="top" class="row1">{image_votes_user_1}</td>
<td valign="top" class="row1">{image_votes_cat_1}</td>
<td valign="top" class="row1" nowrap>{image_votes_number_1}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>2</b></td>
<td valign="top" class="row2">{image_votes_2}</td>
<td valign="top" class="row2">{image_votes_user_2}</td>
<td valign="top" class="row2">{image_votes_cat_2}</td>
<td valign="top" class="row2" nowrap>{image_votes_number_2}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>3</b></td>
<td valign="top" class="row1">{image_votes_3}</td>
<td valign="top" class="row1">{image_votes_user_3}</td>
<td valign="top" class="row1">{image_votes_cat_3}</td>
<td valign="top" class="row1" nowrap>{image_votes_number_3}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>4</b></td>
<td valign="top" class="row2">{image_votes_4}</td>
<td valign="top" class="row2">{image_votes_user_4}</td>
<td valign="top" class="row2">{image_votes_cat_4}</td>
<td valign="top" class="row2" nowrap>{image_votes_number_4}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>5</b></td>
<td valign="top" class="row1">{image_votes_5}</td>
<td valign="top" class="row1">{image_votes_user_5}</td>
<td valign="top" class="row1">{image_votes_cat_5}</td>
<td valign="top" class="row1" nowrap>{image_votes_number_5}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>6</b></td>
<td valign="top" class="row2">{image_votes_6}</td>
<td valign="top" class="row2">{image_votes_user_6}</td>
<td valign="top" class="row2">{image_votes_cat_6}</td>
<td valign="top" class="row2" nowrap>{image_votes_number_6}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>7</b></td>
<td valign="top" class="row1">{image_votes_7}</td>
<td valign="top" class="row1">{image_votes_user_7}</td>
<td valign="top" class="row1">{image_votes_cat_7}</td>
<td valign="top" class="row1" nowrap>{image_votes_number_7}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>8</b></td>
<td valign="top" class="row2">{image_votes_8}</td>
<td valign="top" class="row2">{image_votes_user_8}</td>
<td valign="top" class="row2">{image_votes_cat_8}</td>
<td valign="top" class="row2" nowrap>{image_votes_number_8}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>9</b></td>
<td valign="top" class="row1">{image_votes_9}</td>
<td valign="top" class="row1">{image_votes_user_9}</td>
<td valign="top" class="row1">{image_votes_cat_9}</td>
<td valign="top" class="row1" nowrap>{image_votes_number_9}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>10</b></td>
<td valign="top" class="row2">{image_votes_10}</td>
<td valign="top" class="row2">{image_votes_user_10}</td>
<td valign="top" class="row2">{image_votes_cat_10}</td>
<td valign="top" class="row2" nowrap>{image_votes_number_10}</td>
</tr>
<tr>
<td class="head1" valign="top" colspan="5"> {lang_top_image_hits}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>1</b></td>
<td valign="top" class="row1">{image_hits_1}</td>
<td valign="top" class="row1">{image_hits_user_1}</td>
<td valign="top" class="row1">{image_hits_cat_1}</td>
<td valign="top" class="row1" nowrap>{image_hits_number_1}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>2</b></td>
<td valign="top" class="row2">{image_hits_2}</td>
<td valign="top" class="row2">{image_hits_user_2}</td>
<td valign="top" class="row2">{image_hits_cat_2}</td>
<td valign="top" class="row2" nowrap>{image_hits_number_2}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>3</b></td>
<td valign="top" class="row1">{image_hits_3}</td>
<td valign="top" class="row1">{image_hits_user_3}</td>
<td valign="top" class="row1">{image_hits_cat_3}</td>
<td valign="top" class="row1" nowrap>{image_hits_number_3}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>4</b></td>
<td valign="top" class="row2">{image_hits_4}</td>
<td valign="top" class="row2">{image_hits_user_4}</td>
<td valign="top" class="row2">{image_hits_cat_4}</td>
<td valign="top" class="row2" nowrap>{image_hits_number_4}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>5</b></td>
<td valign="top" class="row1">{image_hits_5}</td>
<td valign="top" class="row1">{image_hits_user_5}</td>
<td valign="top" class="row1">{image_hits_cat_5}</td>
<td valign="top" class="row1" nowrap>{image_hits_number_5}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>6</b></td>
<td valign="top" class="row2">{image_hits_6}</td>
<td valign="top" class="row2">{image_hits_user_6}</td>
<td valign="top" class="row2">{image_hits_cat_6}</td>
<td valign="top" class="row2" nowrap>{image_hits_number_6}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>7</b></td>
<td valign="top" class="row1">{image_hits_7}</td>
<td valign="top" class="row1">{image_hits_user_7}</td>
<td valign="top" class="row1">{image_hits_cat_7}</td>
<td valign="top" class="row1" nowrap>{image_hits_number_7}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>8</b></td>
<td valign="top" class="row2">{image_hits_8}</td>
<td valign="top" class="row2">{image_hits_user_8}</td>
<td valign="top" class="row2">{image_hits_cat_8}</td>
<td valign="top" class="row2" nowrap>{image_hits_number_8}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>9</b></td>
<td valign="top" class="row1">{image_hits_9}</td>
<td valign="top" class="row1">{image_hits_user_9}</td>
<td valign="top" class="row1">{image_hits_cat_9}</td>
<td valign="top" class="row1" nowrap>{image_hits_number_9}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>10</b></td>
<td valign="top" class="row2">{image_hits_10}</td>
<td valign="top" class="row2">{image_hits_user_10}</td>
<td valign="top" class="row2">{image_hits_cat_10}</td>
<td valign="top" class="row2" nowrap>{image_hits_number_10}</td>
</tr>
<tr>
<td class="head1" valign="top" colspan="5"> {lang_top_image_downloads}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>1</b></td>
<td valign="top" class="row1">{image_downloads_1}</td>
<td valign="top" class="row1">{image_downloads_user_1}</td>
<td valign="top" class="row1">{image_downloads_cat_1}</td>
<td valign="top" class="row1" nowrap>{image_downloads_number_1}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>2</b></td>
<td valign="top" class="row2">{image_downloads_2}</td>
<td valign="top" class="row2">{image_downloads_user_2}</td>
<td valign="top" class="row2">{image_downloads_cat_2}</td>
<td valign="top" class="row2" nowrap>{image_downloads_number_2}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>3</b></td>
<td valign="top" class="row1">{image_downloads_3}</td>
<td valign="top" class="row1">{image_downloads_user_3}</td>
<td valign="top" class="row1">{image_downloads_cat_3}</td>
<td valign="top" class="row1" nowrap>{image_downloads_number_3}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>4</b></td>
<td valign="top" class="row2">{image_downloads_4}</td>
<td valign="top" class="row2">{image_downloads_user_4}</td>
<td valign="top" class="row2">{image_downloads_cat_4}</td>
<td valign="top" class="row2" nowrap>{image_downloads_number_4}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>5</b></td>
<td valign="top" class="row1">{image_downloads_5}</td>
<td valign="top" class="row1">{image_downloads_user_5}</td>
<td valign="top" class="row1">{image_downloads_cat_5}</td>
<td valign="top" class="row1" nowrap>{image_downloads_number_5}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>6</b></td>
<td valign="top" class="row2">{image_downloads_6}</td>
<td valign="top" class="row2">{image_downloads_user_6}</td>
<td valign="top" class="row2">{image_downloads_cat_6}</td>
<td valign="top" class="row2" nowrap>{image_downloads_number_6}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>7</b></td>
<td valign="top" class="row1">{image_downloads_7}</td>
<td valign="top" class="row1">{image_downloads_user_7}</td>
<td valign="top" class="row1">{image_downloads_cat_7}</td>
<td valign="top" class="row1" nowrap>{image_downloads_number_7}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>8</b></td>
<td valign="top" class="row2">{image_downloads_8}</td>
<td valign="top" class="row2">{image_downloads_user_8}</td>
<td valign="top" class="row2">{image_downloads_cat_8}</td>
<td valign="top" class="row2" nowrap>{image_downloads_number_8}</td>
</tr>
<tr>
<td valign="top" class="row1" align="center"><b>9</b></td>
<td valign="top" class="row1">{image_downloads_9}</td>
<td valign="top" class="row1">{image_downloads_user_9}</td>
<td valign="top" class="row1">{image_downloads_cat_9}</td>
<td valign="top" class="row1" nowrap>{image_downloads_number_9}</td>
</tr>
<tr>
<td valign="top" class="row2" align="center"><b>10</b></td>
<td valign="top" class="row2">{image_downloads_10}</td>
<td valign="top" class="row2">{image_downloads_user_10}</td>
<td valign="top" class="row2">{image_downloads_cat_10}</td>
<td valign="top" class="row2" nowrap>{image_downloads_number_10}</td>
</tr>
</table></td>
</tr>
</table>
<p> </p>
</td>
</tr>
</table></TD>
</TR>
</TABLE>
<TABLE WIDTH=720 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
<TR>
<TD> <IMG SRC="{template_url}/images/footer_01.gif" WIDTH=720 HEIGHT=20 ALT=""></TD>
</TR>
<TR>
<TD height="30" background="{template_url}/images/barbg.gif"> </TD>
</TR>
<TR>
<TD> <IMG SRC="{template_url}/images/footer_03.gif" WIDTH=720 HEIGHT=10 ALT=""></TD>
</TR>
</TABLE></td>
</tr>
</table>
{footer}
-
I just tryed this code and it worked for me:
<?php
srand(microtime() * 1000000);
echo "<img src=\"/pics/top_".sprintf("%02d", rand(1,2)).".gif\">";
?>
P.S. top.html template is for top.php file, not that its being used by every page as top part ;)
also, check out FAQ for how to use PHP in the template, u can not use <? ?> u must use <?php ?>
-
Perfect. :)
Your code is alot shorter than mine. haha works good aswell.
Thanks.
P.S Maybe if others wanted to use this feature i could release it as a tiny mod? Would be my first to release anyways.
-
yes, sure, go ahead.
P.S. I forgot to mention, that with my variant u can have up to 100 images, the name must be in this format: top_XX.gif where XX is a number from 00 to 99 (note, number from 0 to 9 must have leading 0 infront 01, 02, etc)
if more images added, numbers in rand(1,2) must be adjusted as well (well, u know it ;))
-
Yeps. I got it all sorted. works great. Had to do it for several .html files though. But its easy enough. If i get time tommorow i'll type up a manual. Put him up. simple enough.