collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 306
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

If you're interested in helping other members with support requests, consider joining the Community Support Helpers group.

Author Topic: Random banner block  (Read 13457 times)

0 Members and 1 Guest are viewing this topic.

Offline Verso

  • Semi Newbie
  • *
  • Posts: 37
  • Gender: Male
    • The Suffolk Sports Forum
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Random banner block
« on: April 21, 2009, 04:06:36 AM »
I am looking for a block that will show a random banner.


Any helpers?

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Random banner block
« Reply #1 on: April 21, 2009, 06:46:37 AM »
That should be easy to do with a PHP block. Below is some example code that you could use.

Code: [Select]
$banners = array(
'http://au.php.net/images/php.gif',
'',
'',
);

echo '<img src="', $banners[rand(0, count($banners) - 1)], '" alt="" />';

The banners array can hold a list of images (banners) that will be shown randomly.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline Verso

  • Semi Newbie
  • *
  • Posts: 37
  • Gender: Male
    • The Suffolk Sports Forum
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: Random banner block
« Reply #2 on: April 21, 2009, 08:01:03 AM »
Thanks for your input but my coding knowledge is next to nothing......


The 3 logos I would like to be included are:-

http://www.suffolksportsforum/forumimages/fss.jpg

http://www.suffolksportsforum/forumimages/coastal.jpg

http://www.suffolksportsforum/forumimages/premier.gif



Could you amend the code for me please?



Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Random banner block
« Reply #3 on: April 21, 2009, 08:06:32 AM »
Code: [Select]
$banners = array(
   'http://www.suffolksportsforum.com/forumimages/fss.jpg',
   'http://www.suffolksportsforum.com/forumimages/coastal.jpg',
   'http://www.suffolksportsforum.com/forumimages/premier.gif',
);

echo '<img src="', $banners[rand(0, count($banners) - 1)], '" alt="" />';
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline Verso

  • Semi Newbie
  • *
  • Posts: 37
  • Gender: Male
    • The Suffolk Sports Forum
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: Random banner block
« Reply #4 on: April 21, 2009, 08:18:51 AM »
Sorry to be a nuisance but the block just appears empty

Offline Eliana Tamerin

  • Comrade
  • *
  • Posts: 2889
  • Gender: Female
  • SMF Version: 2 RC2
  • SP Version: 2.3.2
Re: Random banner block
« Reply #5 on: April 21, 2009, 10:42:22 AM »
That's because you forgot the .co.uk on every one of those images. Here's what you need:

Code: [Select]
$banners = array(
   'http://www.suffolksportsforum.co.uk/forumimages/fss.jpg',
   'http://www.suffolksportsforum.co.uk/forumimages/coastal.jpg',
   'http://www.suffolksportsforum.co.uk/forumimages/premier.gif',
);

echo '<img src="', $banners[rand(0, count($banners) - 1)], '" alt="" />';
« Last Edit: April 21, 2009, 10:44:55 AM by Eliana Tamerin »
Ms. Eliana TamerinIt should be painfully obvious by now that I don't respond to support PMs. Don't send me PMs for support. They will be ignored and deleted, post on the Support Boards to get support.

Offline Verso

  • Semi Newbie
  • *
  • Posts: 37
  • Gender: Male
    • The Suffolk Sports Forum
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: Random banner block
« Reply #6 on: April 21, 2009, 10:53:42 AM »
That's because you forgot the .co.uk on every one of those images. Here's what you need:

Code: [Select]
$banners = array(
   'http://www.suffolksportsforum.co.uk/forumimages/fss.jpg',
   'http://www.suffolksportsforum.co.uk/forumimages/coastal.jpg',
   'http://www.suffolksportsforum.co.uk/forumimages/premier.gif',
);

echo '<img src="', $banners[rand(0, count($banners) - 1)], '" alt="" />';
[/quote



How silly do I feel! putting .com instead of .co.uk!!!!


Thanks to both of you for your help - One last thing, can I add hyperlinks to the banners? and how..........

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Random banner block
« Reply #7 on: April 21, 2009, 07:41:30 PM »
That should be easy, if you want the same link for every banner then use this code:
Code: [Select]
$banners = array(
   'http://www.suffolksportsforum.co.uk/forumimages/fss.jpg',
   'http://www.suffolksportsforum.co.uk/forumimages/coastal.jpg',
   'http://www.suffolksportsforum.co.uk/forumimages/premier.gif',
);

echo '<a href="http://www.suffolksportsforum.co.uk"><img src="', $banners[rand(0, count($banners) - 1)], '" alt="" /></a>';

If you want a different link for each banner then use this code:
Code: [Select]
$banners = array(
  array('http://www.suffolksportsforum.co.uk/forumimages/fss.jpg', 'http://www.suffolksportsforum.co.uk'),
  array('http://www.suffolksportsforum.co.uk/forumimages/coastal.jpg', 'http://www.suffolksportsforum.co.uk'),
   array('http://www.suffolksportsforum.co.uk/forumimages/premier.gif', 'http://www.suffolksportsforum.co.uk'),
);

$rand = rand(0, count($banners) - 1);
echo '<a href="', $banners[$rand][1], '"><img src="', $banners[$rand][0], '" alt="" /></a>';

You can change the 'http://www.suffolksportsforum.co.uk' url to alter the location that they link to. :)
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

willerby

  • Guest
Re: Random banner block
« Reply #8 on: April 22, 2009, 03:03:26 AM »
Thanks for this code LHVWB, really useful in so many ways.

Simple to amend for special offers, random forum links from a subset of posts chosen by admin as well as ads.

 8)

Offline Verso

  • Semi Newbie
  • *
  • Posts: 37
  • Gender: Male
    • The Suffolk Sports Forum
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: Random banner block
« Reply #9 on: April 22, 2009, 04:14:18 AM »
Yeah it's quality.


Thanks very much for the help. One more quick question though:-

Can I add any text to this block and (oh thats two questions) can these links open in another page?
« Last Edit: April 22, 2009, 04:17:45 AM by Verso »

willerby

  • Guest
Re: Random banner block
« Reply #10 on: April 24, 2009, 07:37:02 AM »
If you want a different link for each banner AND open in a new window then use this code:

Code: [Select]
$banners = array(
  array('http://www.suffolksportsforum.co.uk/forumimages/fss.jpg', 'http://www.suffolksportsforum.co.uk'),
  array('http://www.suffolksportsforum.co.uk/forumimages/coastal.jpg', 'http://www.suffolksportsforum.co.uk'),
   array('http://www.suffolksportsforum.co.uk/forumimages/premier.gif', 'http://www.suffolksportsforum.co.uk'),
);

$rand = rand(0, count($banners) - 1);
echo '<a href="', $banners[$rand][1], '" target="_blank"><img src="', $banners[$rand][0], '" alt="" /></a>';

Offline dougsbrat

  • Jr. Member
  • **
  • Posts: 55
  • Pull my finger!
Re: Random banner block
« Reply #11 on: April 24, 2009, 09:43:40 AM »
THANKS for a great block!  ;D

Offline dougsbrat

  • Jr. Member
  • **
  • Posts: 55
  • Pull my finger!
Re: Random banner block
« Reply #12 on: June 06, 2009, 07:21:48 PM »
Updated SP 2.2.2
now "Random Banner" shows nothing
 :dead:

Offline geekfairy

  • Semi Newbie
  • *
  • Posts: 19
  • SMF Version: 1.1.10
  • SP Version: 2.3.1
Re: Random banner block
« Reply #13 on: September 07, 2009, 02:59:07 AM »
This works in the preview, but when I try to add the block it tells me there is a syntax error.

Any ideas what is causing it?

Thanks  :)

Offline geekfairy

  • Semi Newbie
  • *
  • Posts: 19
  • SMF Version: 1.1.10
  • SP Version: 2.3.1
Re: Random banner block
« Reply #14 on: September 10, 2009, 11:02:00 PM »
Nobody knows the answer?

Hmm, I don't understand why it works in preview but won't let me add the block :/

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Random banner block
« Reply #15 on: September 11, 2009, 02:05:58 AM »
Possibly an issue with the PHP syntax checking, try turning on the 'Disable PHP Validation' general setting.

Also, could you please post the exact code you are using? If there is an issue with the PHP syntax validation, then it would be quite useful.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline geekfairy

  • Semi Newbie
  • *
  • Posts: 19
  • SMF Version: 1.1.10
  • SP Version: 2.3.1
Re: Random banner block
« Reply #16 on: September 11, 2009, 02:25:07 AM »
Thanks, that did the trick.

Sorry, I didn't post the code because it was the same as the one above.

Thankyou :)

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Random banner block
« Reply #17 on: September 26, 2009, 10:32:30 PM »
geekfairy,
Could you please post or send me (via PM) the exact code that you use in your PHP block? The code above returns no issues for me with SP 2.3 and SMF 1.1.10 or SMF 2RC1.2.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline jimsz

  • Semi Newbie
  • *
  • Posts: 10
  • SMF Version: 1.1.10
  • SP Version: 2.3.1
Re: Random banner block
« Reply #18 on: December 31, 2009, 10:22:52 AM »
This code works great for a rotating banner but I have a couple questions - I'd like the image centered and any code I add results in a syntax error.

Also, I'd like to add some static text to the same block but that too results into a syntax error.

Offline MultiformeIngegno

  • Full Member
  • ***
  • Posts: 127
  • Gender: Male
  • SMF Version: None
  • SP Version: None
Re: Random banner block
« Reply #19 on: February 06, 2010, 12:12:13 PM »
Is it possibile to have for each image a different caption text?
For example under the first image I'd like to have "First Image" (after a <br />), then under the second "Secondo Image", and so on... :)

Offline haito

  • Semi Newbie
  • *
  • Posts: 46
  • Gender: Male
  • maybe lucky
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Random banner block
« Reply #20 on: March 22, 2010, 02:13:52 PM »
Is it possibile to have for each image a different caption text?
For example under the first image I'd like to have "First Image" (after a <br />), then under the second "Secondo Image", and so on... :)
- brrr

Offline Stigmartyr

  • Jr. Member
  • **
  • Posts: 72
  • Gender: Male
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: Random banner block
« Reply #21 on: March 23, 2010, 03:14:09 AM »
I thought I might share a nifty banner rotator script I use.  You just drop all your images in a folder, and put a single php file in there with the images.  Then you call the php file as if it were an image and it rotates everything in that folder randomly.

I've attached the file below.


If this doesn't make sense, you just create a folder, lets call it banners.

You just put all your image files in /banners

Put the BannerRotator.php file in /banners and then call /banners/BannerRotator.php where you would call the image (i.e. <img src="/BannerRotator.php" )  works with BBC too.

Offline Old Fossil

  • Beta Tester
  • *
  • Posts: 796
  • Gender: Male
  • SMF Version: 2.0.4
  • SP Version: 2.3.5
Re: Random banner block
« Reply #22 on: May 02, 2010, 11:42:31 AM »
Hey stigmartyr

Any chance of having a peep at ya forum so we can see what it should look like?
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast

Offline Stigmartyr

  • Jr. Member
  • **
  • Posts: 72
  • Gender: Male
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: Random banner block
« Reply #23 on: May 13, 2010, 02:57:09 AM »
Hey stigmartyr

Any chance of having a peep at ya forum so we can see what it should look like?

Sorry about taking a week to get back to you!

Here it is: http://stangnation.com/

It's the header banner that rotates on refresh. 

I've removed as much flash as I possible could in favor of jQuery