I see I’m the only person to have problems with this snippet. That’s not a good sign.
I created a new snippet called "ClientQuote".
I pasted the following code into it.
<?php
// RandomQuote
// Snippet to produce by sottwell.
// Posted by web_designer.
// Dated 25th Sepember 2006.
$resourceparent = $quoteid; // the folder that contains quote documents
$output = ''; // initialise the quote variable
$resource = $modx->getActiveChildren($resourceparent,'createdon', 'DESC', $fields='content');
$limit=count($resource);
if($limit<1) {
$output .= "No entries found.<br />";
return $output;
}
$random = (rand(1, $limit) - 1);
$output .= $resource[$random]['content']; // get a random quote
return $output;
?>
I created a new container called "Random Quotes". I tried it both published and non published.
Here are the setting for the container (ID is #5)-
Page data
General
Title: Random Quotes
Long title: (Not set)
Description: (Not set)
Type: Document
Document’s alias: (Not set)
Keywords: (Not set)
Changes
Created: 13/01/07 21:49:54 (Admin)
Edited: 15/01/07 09:42:11 (Admin)
Status
Status: Published
Publish date: (Not set)
Un-publish date: (Not set)
Cacheable: No
Searchable: No
Menu index: 4
Show in menu: No
Web access: Public
Manager access: Public
Markup/structure
Uses template:
Edit using rich text editor: Yes
Document is container: Yes
I then put it in my template header2 chunk like this -
<div id="head2">
<div class="head2left">
</div>
<div class="head2right">
<h2>Welcome to</h2>
<h3><a href="[~[(site_start)]~]">[(site_name)]</a></h3>
<p>
[[!ClientQuote?quoteid=`5`!]]
</p>
</div>
</div>
I created 2 quote documents (tree as follows)-
Random Thoughts
Home (1)
Random Quotes (5)
Catie Curtis - Silhouette (7)
Default - Movin On (6)
Photos (2)
Music (3)
Forum (4)
Can you tell what I did wrong?
The quotes are not displaying.