================================================================== Snippet-title: dart v1.3 Creator: Graham Keellings E-mail: pivot@keellings.com Website: http://www.keellings.com/software/pivot.php Creation date: 20 February 2006, Sentosa Island, Singapore ================================================================== Content of zipped file: ----------------------- snippet_dart.php readme_dart.txt (this file) Usage: ------ 1) unpack this package in your extensions/snippets/ folder. 2) edit the $dart_data at the top of the file, or create an external data file in your templates directory. The format of each line is | where is some witty or deeply philosophical saying, and are the odds of it being selected. Note that we do not use percentages here, as you would have to recalclate them every time you add a new text to make them toal 100%. Instead, we take the simplistic approach that a text with odds of 2 is twice as like to appears as one with odds of 1. e.g, the snippet contains this by default global $dart_data; $dart_data[] = '1|Random text 1'; $dart_data[] = '3|Random text 2, which is 3 times as likely to be selected'; Or you could put this in a fiel called dart.txt in your templates directory. 1|Random text 1 3|Random text 2, which is 3 times as likely to be selected 3) place a [[dart]] tag, with the appropriate parameters, in any of your template files, whereever you want the random text to appear 4) rebuild the FrontPage(s). Description: ------------ * A simple snippet to Display A Random Text from an array declared within * the snippet, or in an external file in your templates directory. * * Visit http://www.keellings.com/blog/_demos/dart.php to see it * in action Parameters: ----------- * @param bool allowDebugComments - if 0, the snippet will not output any * HTML comments, which is does to help * debugging. * I added this becuase I use the snippet to * generate a random page title for my blog's * frontpage, but some browsers show the HTML * comments as part of the page title, either * at the bottom of the page, in the status * bar, or as a tooltip on tabbed browsers. * Default = 1, show HTML comments in output. * @param string dataFile - if supplied, the texts will be taken from * the specified file in your template * directory. This lets you edit the file dirctly * within Pivot from Adminisatration/Templates. * If not supplied, the texts will be taken * from the array declared at the top of this * file (this is the default). * So that you don't have to type long file * names each time, if you pass this parameter * as '.', then the snippet will look for a * file named "dart.txt". * Note that the snippet treats each line of * the file as a separate string. You can * achieve multi-line output with HTML tags. * e.g "Line 1
Line 2" * @param string separator - this is the spearator character for each * array entry above or line of the data file * which look like *