Generate random content from text, lists, numbers, hashes, and more!
The Randomizer plugin lets you generate random content from text, lists, numbers, hashes, and more!
The Generate tag is used to generate and output random values. It can output letters, numbers, or specific patterns (like sha1 hashes).
In this example, we will use the tag twice to create random codes that could be used for redemption codes or similar. It avoids characters that are ambiguous in many typefaces (0
, O
, l
, 1
, etc.) to prevent end user errors.
{exp:randomizer:generate type='alnum' length='4' avoid_ambiguous='yes'}-{exp:randomizer:generate type='alnum' length='4' avoid_ambiguous='yes'}
The Choose tag is used to output one item from among a list of items. The list can be created with dynamic content or statically.
In this example, we will use it to choose a famous quote at random.
<blockquote>
{exp:randomizer:choose}
{randomizer:items}I find that the harder I work, the more luck I seem to have. - Thomas Jefferson{/randomizer:items}
{randomizer:items}Don't stay in bed, unless you can make money in bed. - George Burns{/randomizer:items}
{randomizer:items}We didn't lose the game; we just ran out of time. - Vince Lombardi{/randomizer:items}
{randomizer:items}If everything seems under control, you're not going fast enough. - Mario Andretti{/randomizer:items}
{randomizer:items}Reality is merely an illusion, albeit a very persistent one. - Albert Einstein{/randomizer:items}
{randomizer:items}Adventure is worthwhile. - Aesop{/randomizer:items}
{randomizer:items}No legacy is so rich as honesty. - William Shakespeare{/randomizer:items}
{randomizer:items}You will never live if you are looking for the meaning of life. - Albert Camus{/randomizer:items}
{randomizer:items}The price of anything is the amount of life you exchange for it. - Henry David Thoreau{/randomizer:items}
{randomizer:items}Chance favors the prepared mind. - Louis Pasteur{/randomizer:items}
{randomizer:items}Freedom of Press is limited to those who own one. - H.L. Mencken{/randomizer:items}
{randomizer:items}I do not fear computers. I fear the lack of them. - Isaac Asimov{/randomizer:items}
{randomizer:items}Never trust a computer you can't throw out a window. - Steve Wozniak{/randomizer:items}
{randomizer:items}Do, or do not. There is no 'try'. - Yoda{/randomizer:items}
{/exp:randomizer:choose}
</blockquote>
In this example, we’ll choose one title at random from all entries being displayed. The rest of the Channel Entries tag’s output is displayed as normal.
{exp:randomizer:chooser}
{exp:channel:entries channel='blog' limit='10'}
{randomizer:items}{title}{/randomizer:items}
{/exp:channel:entries}
{/exp:randomizer:chooser}
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.