Author |
Message |
Maclain
Regular
![Regular Regular](modules/Forums/images/ranks/2stars.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Feb 25, 2006
Posts: 60
Location: England
|
Posted:
Tue Nov 25, 2008 2:05 am |
|
OK.
Being as I've been helped here before, I thought I'd pop back with yet another dilemma!
There is a site that i'm involved with, that has a list of adverts in a block on the home page.
As new sponsors come onboard, they get added to the bottom of the list.
Now some of these have (rightly so) shown a discomfort in paying to have an advert on the bottom of the page, so now what I wan't to do is have these images displayed randomly on page load.
All the images are stored in various formats in the same folder
../images/advertising
the current block: block-advertising.php has the following code
Code:
<?php
if (eregi('block-adverts.php', $_SERVER['PHP_SELF'])) {
Header('Location: index.php');
die();
}
$content = "<center>";
$content .= "<p><a href=\"http://yorkshirekoi.co.uk/_launch.php?id=170\" target=\"_blank\"><img src=\"/images/advertising/mholmesmain11-07.jpg\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://www.selectivekoisales.co.uk/\" target=\"_blank\"><img src=\"/images/advertising/SELECTIVEKOI11-07.jpg\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://www.absolute-koi.com\" target=\"_blank\"><img src=\"/images/0308.gif\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://bkksys.co.uk\" target=\"_blank\"><img src=\"/images/advertising/koimastersbanner.jpg\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://www.koiplus.com\" target=\"_blank\"><img src=\"/images/koiplus140408.JPG\"></a></p>";
$content .= "<p><a href=\"http://www.shingoi.com/\" target=\"_blank\"><img src=\"/images/advertising/shingoi1.gif\"></a></p>";
$content .= "<p><a href=\"http://www.jammyfoldkoi.com/\" target=\"_blank\"><img src=\"/images/advertising/jammy.gif\"></a></p>";
$content .= "<p><a href=\"http://www.lambournkoi.co.uk/\" target=\"_blank\"><img src=\"/images/advertising/lambourn.jpg\"></a></p>";
$content .= "<p><a href=\"http://www.shingoi.com/\" target=\"_blank\"><img src=\"/images/advertising/shingoi2.gif\"></a></p>";
$content .= "<p><a href=\"http://www.yourkoi.co.uk/\" target=\"_blank\"><img src=\"/images/advertising/yourkoi.gif\"></a></p>";
$content .= "<p><a href=\"http://www.migoto-koi.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/migotokoi.JPG\"></a></p>";
$content .= "<p><a href=\"http://www.koi-uk.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/koiuk.png\"></a></p>";
$content .= "<p><a href=\"http://www.pastureslodge.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/pastures.png\"></a></p>";
$content .= "<p><a href=\"http://www.richdon-koi.com/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/richdon.gif\"></a></p>";
$content .= "<p><a href=\"http://www.koicarp.org.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/koiwater.jpg\"></a></p>";
$content .= "<p><a href=\"http://www.uknishikigoi.com/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/uknishi.gif\"></a></p>";
$content .= "<p><a href=\"http://www.cicscreens.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/cicscreens.jpg\"></a></p>";
$content .= "</center>";
$content .= "<br>";
$content .= "<p><font size=\"10\"> Interested in becoming a sponsor? click <a href=\"http://bkksys.co.uk/modules.php?name=Advertising\">HERE</a>.</p></font>";
?>
|
As you can see, my code is probably very crude and amaturish(f7)?
Any ideas how I can either alter the block, or create a new one to display the images in a new order on each page load?
I'd also like it fairly easily editable, so as new sponsors arrive, I can add them.
Thanks in advance - Any help / advice greatly appreciated!
Chris.
P.S I'm not sure if this makes any difference, but the society involved is a non profit society. Just didn't want to think I was trying to make money from your help:-) |
_________________ Insert funky message here: |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
evaders99
Former Moderator in Good Standing
![](modules/Forums/images/avatars/803d73f6452557b947721.jpg)
Joined: Apr 30, 2004
Posts: 3221
|
Posted:
Tue Nov 25, 2008 2:10 am |
|
If you use the built-in features of the banners script or Advertising (in newer phpNukes), you will get randomization essentially for free. No messing with any HTML or PHP code |
_________________ - Only registered users can see links on this board! Get registered or login! -
Need help? Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Maclain
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Nov 25, 2008 2:26 am |
|
I;ve played about with it as I use it on another site.
The only problem is it only displays one advert. I need to display all of them at once on the page.... |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
evaders99
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Nov 25, 2008 12:00 pm |
|
Ah that will be a different issue. I think you can still use the banner tables to store the ads. But need to write some code to generate the random order. You could do it using an "ORDER BY RAND()" SQL statement |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Maclain
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Nov 26, 2008 3:06 am |
|
Sounds interesting...
None of the images are stored in the tables at the moment, but that's easily sorted.
As for the sql code and php block code involved in getting it to display correctly, well I wouldn't have a scooby doo.
I'd be willing to attempt to write the block though, if your willing to help / guide me along the way?
TIA! |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Maclain
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Nov 29, 2008 7:21 am |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Guardian2003
Site Admin
![](modules/Forums/images/avatars/125904890252d880f79f312.png)
Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
Posted:
Sat Nov 29, 2008 1:12 pm |
|
Did you want to share the code in case it helps anyone else? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Maclain
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Dec 01, 2008 3:41 am |
|
Sorry!
That would be a good idea
Code:
<?php
/*******************************
Random Image block
Codezwiz Network, LLC.
http://www.codezwiz.com/
© 2002-2009
********************************/
if (eregi('block-adverts.php', $_SERVER['PHP_SELF'])) {
Header('Location: index.php');
die();
}
$show_credit = 1;
$content = "";
$randimg = array();
//Add one of these $randimg[NUMBER] array for each image.
//Add as many as you like but be sure to increment the array $randimg[1], $randimg[2], etc.
$randimg[1] = array(
"http://yorkshirekoi.co.uk/_launch.php?id=170", //Link
"/images/advertising/mholmesmain11-07.jpg", //Image
"", //image alt (mouseover text)
"", //image width
"" //image height
);
$randimg[2] = array(
"http://www.selectivekoisales.co.uk/", //Link
"/images/advertising/SELECTIVEKOI11-07.jpg", //Image
"", //image alt (mouseover text)
"", //image width
"" //image height
);
$randimg[3] = array(
"http://www.absolute-koi.com/", //Link
"/images/0308.gif", //Image
"", //image alt (mouseover text)
"", //image width
"" //image height
);
$randimg[4] = array(
"http://bkksys.co.uk/", //Link
"/images/advertising/koimastersbanner.jpg", //Image
"", //image alt (mouseover text)
"", //image width
"" //image height
);
//No need to edit below this line...
if ($show_credit) {
$randimg[count($randimg)+1] = array(
"http://www.codezwiz.com/", //Link
"http://www.codezwiz.com/images/links/codezwiz12.gif", //Image
"Codezwiz >> PHP Nuke themes and scripts development and support", //image alt (mouseover text)
"392", //image width
"72" //image height
);
}
srand((double)microtime()*1000000);
$res = array();
$n = count($randimg);
for ($i=0;$i<$n;$i++) {
$res[$i] = 0;
}
for ($i=0;$i<$n;$i++) {
do {
$rv = rand(0, $n);
$ban = 0;
for ($j=0;$j<$n;$j++) {
if ($res[$j] == $rv) {
$ban = 1;
break;
}
}
}
while($ban == 1);
$res[$i] = $rv;
}
for ($i=0;$i<$n;$i++) {
$alt = ($randimg[$res[$i]][2] != "") ? " title=\"".$randimg[$res[$i]][2]."\"" : " title=\"".$randimg[$res[$i]][0]."\"";
$width = ($randimg[$res[$i]][3] > 0) ? " width=\"".$randimg[$res[$i]][3]."\"" : "";
$height = ($randimg[$res[$i]][4] > 0) ? " height=\"".$randimg[$res[$i]][4]."\"" : "";
$content .= "<center><p><a href=\"".$randimg[$res[$i]][0]."\" target=\"_blank\"><img border=\"0\" src=\"".$randimg[$res[$i]][1]."\"".$width."".$height."".$alt." /></center></a></p><br />\n";
}
$content .= "<br />";
$content .= "<p><font size=\"10\">Interested in becoming a sponsor? click <a href=\"http://bkksys.co.uk/modules.php?name=Advertising\">HERE</a>.</font></p>\n";
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|