News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Random BBCode

Started by karlbenson, August 28, 2007, 07:17:44 PM

Previous topic - Next topic

karlbenson



RANDOM BBCODE v1.1
By Karl Benson



Introduction
Enables [random][/random] bbcode to randomly select one or more from your random tags
Use | as a delimiter

Examples
[random]One|Two|Three|Four[/random] would select 1 at random eg Two

To select multiple randomly (between 1-9)
[random=3]One|Two|Three|Four|Five|Six[/random] would select 3 at random eg Three Five Two

You cannot use bbcode or html between the tags. ONLY text.
The function will make a UNIQUE selection. (Never two the same).

Features
o BBCode Button

Installation
Simply install the package to install this modification on the Default theme.

You will also need to place a copy of the random.gif in each of your themes bbc image folders (eg Themes/{themename}/images/bbc)

If your using a language different than the ones supported this mod (listed below), then you will need to add the following to the Modifications.{language}.php for each theme (The language folder can be found eg Themes/{themename}/languages/)

FIND
?>
ADD BEFORE (and translate as necessary the language strings)
$txt['random_desc'] = 'Random BBCode';

Languages
o Supports
- English/English-utf8
- English_British/English_British-utf8
I welcome translations for any other languages which SMF Supports.
Please translate the following and post them in the mods support topic.
$txt['random_desc'] = 'Random BBCode';

Support
Please use the modification thread for support with this modification.
(Please don't ask me to do the edits for you)

Changelog
1.0 - 17th August 2007
o Initial release
1.0 - 23rd November 2007
o Added English-utf8 support
o Added English_British/English_British-utf8 support

wudthipan

this is good job but why no one response to this post?

thank for your work

and have a little question

the number is random all the time when refresh Are there a way to just random it once per post?


karlbenson

lol,

I think this is just one of the mods which got lost.  Less than a 100 downloads in several months.

Every use of [random] and every refresh of the page will run the random number generator.

Furthermore where you select multiple eg
[random=3]One|Two|Three|Four|Five|Six[/random] would select 3 at random eg Three Five Two
AND it will ONLY choose unique ones, so it will never select Three Three Two

Raziel-chan

Awesome mod, but were you considering making an option to randomize the number just once, the first time you save a message? it would be neat for forum RPGs then.

cya
Raziel-chan

olandir

This is the exact same question I have.

I'd like to make it so that it only makes a random number the first time.

That way if the person goes back and edits their post, the number doesn't change.

You don't have to do it, if you could just point me in the right direction, you're code's not that big, I can do it myself if I know what to look for.

karlbenson

I don't think it would be possible.

Everytime a user went back to edit it, it would give a new number.

уιℓмαz

#6
an unusual modification :D

Turkish translation

$txt['random_desc'] = 'Kelimeler Değişsin';

JamesWC

Interesting mod.

Although BBCode can't be included as options in the list, could this tag be inserted within other BBCode? For example:

[img]http://www.example.com/pictures/[random]horse.jpg|cat.gif|bear.gif|pigeon.jpg[/random][/img]

Would this randomly display one image out of horse.jpg, cat.gif, etc? Or would the code break somewhere along the way?

karlbenson

Bbcode inside inside the [img] tag will not be parsed.

And [random] bbcode will NOT parse any bbcode inside it.

karlbenson

I have reuploaded this mod and screenshots for it.

I am in the process of doing it for ALL my other mods aswell.  Please bear with me.

Advertisement: