Random Content

4 posts by 2 authors in: Forums > CMS Builder
Last Post: July 7, 2009   (RSS)

By Moonworks - July 7, 2009

Is there a simple way to show random content.

I want to show a quote and who said the quote randomly at the top of each page.

The perfect solution would be to have two text boxes, one for the quote and the other for the quoter, then I can work on the look of each bit.

If that isn't pssible, then just to have a wysiwyg editor and show that.
High quality residential training for writers, actors & Film Making - Click Here for further information

Re: [Moonworks] Random Content

By Damon - July 7, 2009

Hi,

Here are some steps and code for you:

Create a section for "Quotes" - Multi Record.

Add a field for the "Quote" - choose textbox.
Add a field for "Quoter" - choose textfield.

Here is some example code to output the quote and quoter randomly:

<?php
require_once "/yourpath/to/the/viewer_functions.php";
list($quotesRecords, $quotesMetaData) = getRecords(array(
'tableName' => 'quotes',
'limit' => '1',
'orderBy' => 'RAND()',
'allowSearch' => '0',
));
?>

<?php foreach ($quotesRecords as $record): ?>
Quote: <?php echo $record['quote'] ?><br/>
Quoter: <strong><?php echo $record['quoter'] ?></strong><br/>
<?php endforeach; ?>


This will randomly output one quote. Add this code to the top of each of your pages or add it using an include.

Hope that helps. :)
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Moonworks] Random Content

By Moonworks - July 7, 2009

It's ok, I just had to remove the require_once "/var/www/vhosts....... line, due to it being an include.

Thanks for the help, and making it so simple [cool]
High quality residential training for writers, actors &amp; Film Making - Click Here for further information