We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Random Number

Development and Programming

Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

The attached add-on files may be out of date. Please visit Devot-ee for the latest versions.

This plugin allows you to output random numbers.

PARAMETERS

1) min - Optional. Allows you to specify the lowest number to return. Default value is “1”.

2) max - Optional. Allows you to specify the highest number to return. Default value is “50”.

3) invalid_input - Optional. Accepts two values: “alert” and “silence”. Default value is “silence”. If the value is “alert”, then in cases when the plugin has some problem with parameters, PHP alert is being shown; if the value is “silence”, then in cases when the plugin has some problem with parameters, it finishes its work without any alert being shown. Set this parameter to “alert” for development, and to “silence” - for deployment.

VARIABLES

The plugin supports one hundred variables of the type outlined below:

{random_number_0}, {random_number_1}, {random_number_2}, {random_number_3}, … {random_number_10}, {random_number_11}, {random_number_13}, …, {random_number_99}

The numbers at the end of variables are used only to differentiate variables from each other.

Conditionals are supported.

EXAMPLE OF USAGE

{exp:random_number min="1" max="10"}

{if random_number_0 > 5}

Some code

{if:else}

Some code

{/if}

{/exp:random_number}

A more complicated example - Random Number plugin together with Child categories and Category Info plugins used to output three random categories:

{exp:cat_info category_id="179" parse="inward"}
{exp:random_number min="1" max="{cat_info_nonempty_subcategories_number}" parse="inward"}
{exp:child_categories parent="179" child_categories_sort_by="name" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="10" site="1" parse="inward"}

{child_category_start}
{if "{random_number_0}" == "{child_category_count}" OR "{random_number_1}" == "{child_category_count}" OR "{random_number_2}" == "{child_category_count}"}

<a href="http://{child_category_url_title}">{child_category_name}</a>, number of entries: {entries_total}
{child_category_description}

{/if}
{child_category_end}

{/exp:child_categories}
{/exp:random_number}
{/exp:cat_info}
       
Adrienne L. Travis's avatar
Adrienne L. Travis
213 posts
16 years ago
Adrienne L. Travis's avatar Adrienne L. Travis

Okay, just ‘cause i’m a geek, here’s my request for addition to this: add an option to use the QRB service to generate REAL random numbers instead of pseudorandom numbers. For more info: http://random.irb.hr/

       
portnull's avatar
portnull
8 posts
15 years ago
portnull's avatar portnull

thanks for this. i use it in combination with the logmein-plugin & SAEF forms to randomly login different users for some added protection.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.