plainblack.com
Username Password
search
Bookmark and Share
Subscribe

Random Thread Macro

^RandomThread( [ startURL, relatives, templateURL ] );
The Collaboration System can be used for much more than just a forum. A few examples of its possible usages are an FAQ, photo gallery, job listings, quotes database or weblog. For these applications (and others that you might think of) it can be nice to display a random entry from such a CS somewhere on your site. That is exactly the functionality that this macro provides.

It displays the start post of a thread that is randomly selected from a (possibly random) CS, depending on the parameters. The way the selected post is displayed is controlled by a template. All the template variables that are normally available in a CS Post template are available in this macro as well.

Parameters

Although all the parameters can be omitted, it usually makes sense to specify them all. If you want to display a random thread from a single CS, we suggest you use the URL of the CS as the startURL and "self" as relatives.

startURL URL of the asset you want to use as the starting point for finding a random CS. If omitted it defaults to 'home' (i.e. the root page of most websites). Must be a valid URL within WebGUI. relatives Only posts from Collaboration Systems that are relatives of the start-asset in this way are used. Allowed values for this parameter are 'siblings', 'children', 'ancestors', 'self', 'descendants' and 'pedigree'. Default value is descendants. templateURL URL of the template to use to display the random thread. Must be a valid URL within WebGUI.

IMPORTANT NOTE: if omitted, a default debug template is used that outputs a list of all the available template variables. Since you almost certainly will not want this output in a production-environment, it makes sense to not omit this parameter.

Examples:

^RandomThread(home/photo_album, descendants, templates/randomPhoto); If you have a page with many subpages with photo galleries, you can use the parameters above to easily retrieve a random thumbnail from all your photo albums. ^RandomThread(home/quotes/quotes-db, self, templates/randomQuote); If you have one CS that you use to keep a database of interesting quotes, you could use the above example to display a random quote on your website. ^RandomThread(home/faq, children, templates/faq); Suppose you have one page with a couple of Collaboration Systems (for different categories of questions), then the example above can be used to display a random question from any category. ^RandomThread; Gets a random post from all Collaboration Systems in root 'home' with debug output.

This Macro may be nested inside other Macros if the post does not contain commas or quotes.

Keywords: macro

Search | Most Popular | Recent Changes | Wiki Home
© 2018 Plain Black Corporation | All Rights Reserved