greetings ...
i am using Jot to gather customer comments on a client’s website, with custom fields, moderation and badwords, etc. however the client then asked for a random comment to be shown in a box on the homepage. i couldn’t find anyway of getting Jot to do this so after reading through documentation and code of other snippets i came up with the following snippet. it works perfectly, but I’m sure there is a better, more elegant/efficient way of doing this. i’m a sucker for efficient code, but i don’t know PHP or the inner working of MODx well, so does anyone want to offer some suggestions? cheers!
<?php
$rsContent = $modx->db->select("id,content", "modx_jot_content", "published=1", "RAND()", "1");
$arr = mysql_fetch_array($rsContent);
$id = $arr['id'];
$content = $arr['content'];
$rsFields = $modx->db->select("content", "modx_jot_fields", "label='name' AND id=".$id);
$arr = mysql_fetch_array($rsFields);
$name = $arr['content'];
$rsFields = $modx->db->select("content", "modx_jot_fields", "label='location' AND id=".$id);
$arr = mysql_fetch_array($rsFields);
$location = $arr['content'];
$strReturn = "<div id='TestimonialHighlightCopy'>".$content."</div><div id='TestimonialHighlightCredit'>- ".$name.", ".$location."</div>";
return $strReturn;
?>