Rotating or random signatures

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Anti-Spam Guide
Locked
User avatar
Dragonwolf
Registered User
Posts: 603
Joined: Mon Aug 20, 2007 7:46 pm

Rotating or random signatures

Post by Dragonwolf » Wed Jun 25, 2008 7:23 pm

In some forums you can have up to five signatures that are chosen at random, somtimes more, usualy typed as normal in the signature box, but with seperators.

Are there any mods for phpbb3 that do this?

User avatar
Dragonwolf
Registered User
Posts: 603
Joined: Mon Aug 20, 2007 7:46 pm

Re: Rotating or random signatures

Post by Dragonwolf » Fri Jun 27, 2008 8:16 pm

*bump*


User avatar
Dragonwolf
Registered User
Posts: 603
Joined: Mon Aug 20, 2007 7:46 pm

Re: Rotating or random signatures

Post by Dragonwolf » Sat Jun 28, 2008 9:22 pm

I can't download the mod, but I wouldn't be able to modify it, I have no idea how to go about learning php scripting.

opalelement
Registered User
Posts: 315
Joined: Wed Dec 27, 2006 4:05 am

Re: Rotating or random signatures

Post by opalelement » Sun Jun 29, 2008 10:51 pm

I made a quick JS one, it still shows everything at first but changes once the page is loaded.

First, insert the JS...
Open ACP > styles > templates > *each template you want to use this with, which should be all templates you have* > oveall_header.html

Code: Select all

// ]]>
Add above

Code: Select all

function letsGoForIt(){
var randomSpans = document.getElementsByTagName('span');
for (var i=0;i<randomSpans.length;i++) {
if(randomSpans[i].title == "randombbc"){

var splitItUp = randomSpans[i].innerHTML.split("|");
var whichToShow = Math.round(Math.random()*(splitItUp.length-1));
randomSpans[i].innerHTML=splitItUp[whichToShow];

}
}
}
Find

Code: Select all

<body id="phpbb" class="section-{SCRIPT_NAME} {S_CONTENT_DIRECTION}">
Replace with

Code: Select all

<body id="phpbb" class="section-{SCRIPT_NAME} {S_CONTENT_DIRECTION}" onload="letsGoForIt();">

Now to add the actual bbcode:

Open ACP > posting > Add new BBCode

Set BBCode usage to:

Code: Select all

[random]{TEXT}[/random]
Set HTML Replacement to:

Code: Select all

<span title="randombbc">{TEXT}</span>
Pros:
-Can use any bbcode combinations such as

Code: Select all

[quote][random]Hello|Hi|Howdy|Hola[/random][/quote]

[random][b]this is bold[/b]|[i]this is italic[/i]|[u]this is underlined[/u]|this is normal[/random]

[random][img]http://www.phpbb.com/community/images/smilies/icon_evil.gif[/img]|mixing images and text[/random]

[random][color=#FF0000]red[/color]|[color=#0040FF]blue[/color]|[color=#008000]green[/color][/random]

[random][url=http://phpbb.com]phpBB Home[/url]|[url=http://phpbb.com/community]phpBB Community Forums[/url]|[/random]
Cons:
-quick display of all contents before replacement

User avatar
Dragonwolf
Registered User
Posts: 603
Joined: Mon Aug 20, 2007 7:46 pm

Re: Rotating or random signatures

Post by Dragonwolf » Wed Jul 02, 2008 8:50 pm

Thanks! I'll try that

opalelement
Registered User
Posts: 315
Joined: Wed Dec 27, 2006 4:05 am

Re: Rotating or random signatures

Post by opalelement » Wed Jul 02, 2008 8:52 pm

It worked on my phpbb test board so I'm sure it will work for you :) I love making bbcodes so if you ever want one just ask (preferably through PM)

User avatar
James78
Registered User
Posts: 811
Joined: Sat Jul 30, 2005 4:54 pm
Location: Washington, USA
Contact:

Re: Rotating or random signatures

Post by James78 » Thu Jul 03, 2008 5:00 am

I cannot provide any php code for this, even though I can make it, but I don't have enough time. However, if you use an apache server, you could make your own php script, that takes a variable, and inserts the strings (image URLs) into an array, then randomize the output of the array, and display the image. And, by using htaccess, you could allow your dynamic loading php script to look like an image when requested:
dynamicimage.php
would also work if you requested:
dynamicimage.png

Code: Select all

Options +FollowSymlinks
RewriteEngine On

RewriteRule ^dynamicimage\.png$ dynamicimage.php [nc]
Or if you wish to have all php scripts work when requesting an extension of png:

Code: Select all

Options +FollowSymlinks
RewriteEngine On

RewriteRule ^(.*)\.png$ $1.php [nc]
"Options +FollowSymlinks" exists to make sure this option is enabled on your server. If this script causes problems, then it probably is enabled on your server, and you should remove this line.
If you encounter what is/or you think is a bug, please report it to the phpBB Bug Tracker

opalelement
Registered User
Posts: 315
Joined: Wed Dec 27, 2006 4:05 am

Re: Rotating or random signatures

Post by opalelement » Sat Jul 05, 2008 6:40 pm

Hope it doesn't bother anyone if I come back to this, but here is a way to hide the contents from flashing before the page is loaded:

Replace the HTML replacement in the BBCode section with this:

Code: Select all

<span title="randombbc" style="display:none">{TEXT}</span>
In the function, find this line:

Code: Select all

randomSpans[i].innerHTML=splitItUp[whichToShow];
Add after:

Code: Select all

randomSpans[i].style.display='';
If anyone finds this useful and likes it please let me know.
This has been updated on my board: http://www.phpbb.crystal-core.info/

fearfactor
Registered User
Posts: 5
Joined: Sun Dec 07, 2008 11:44 am

Re: Rotating or random signatures

Post by fearfactor » Wed Jan 28, 2009 9:13 pm

nice one!! :D

Locked

Return to “[3.0.x] MOD Requests”