We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Announcement Randomizer
Topic Started: Sep 26 2013, 10:19 AM (1,846 Views)
RecAgenda
Member Avatar
Member
[ * ]
Code name: Announcement Randomizer
Date created: 23 SEP 2013
Author(s): Paul James (RecAgenda)
Description: This simple code takes advantage of your board's Layout page and the "notice info" dl class to create a simple announcement header that randomly generates a message on each page load.
Preview: http://w11.zetaboards.com/Rec_Labs/index/

(Released at Outline a few days back; now sharing it here)

Code: HTML
 
<dl class="notice info">
<dt>Heads up!</dt>
<dd>

<script language="Javascript">
<!--
var r_text = new Array ();
r_text[0] = "<img src=\"http://oi54.tinypic.com/2w3u6pl.jpg\"> Announcement #1!";
r_text[1] = "<img src=\"http://oi54.tinypic.com/2w3u6pl.jpg\"> Announcement #2!";
r_text[2] = "<img src=\"http://oi55.tinypic.com/k33iuf.jpg\"> Holy cow! Another announcement!";
var i = Math.floor(3*Math.random())

document.write(r_text[i]);
//
-->
</script>

</dd>
</dl>


In short, make sure the number in "var i = Math.floor(#*Math.random())" equals the amount of arrays (announcements) you have (this counts "r_text[0]" as one of those).

I've seen theme designers use the Notice dl class over and over to put up things like "Top Secret Board, bla blah", but I've noticed that nobody has shared how to do this in case people want to actually use it. So... I'm doing the unspeakable and passing along the info. Call it a crisis of conscience.

You can drop this code, in theory, anywhere in your Layout, but it works best immediately following the opening of your wrap div. You can use this with or without the randomizer (just remove the script and use your own HTML in its place).

If you're using the script, make sure that you escape quotations using a backslash. This goes for any quotation in your arrays, including those within <a href>, <img>, and <font> / <span> tags.

When you load/refresh a page, the script randomly calls up one of your arrays and displays that message in the notice bar. This makes for a clean announcements area that can be used to relay all the information you want to your users without overloading them with it all at the same time.

Now someone pour me a glass of scotch and have fun!
Offline Profile Quote Post Goto Top
 
boujaad
Member
[ * ]
there is any way to use URL bbcode in announcements?
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Use HTML:
Code: HTML
 
<a href="URL">TEXT</a>
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · ZetaBoards Codes & Modifications · Next Topic »
Add Reply